[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH 1/2] xen/arm32: Introduce alternative runtime patching



Hi Konrad,

On 2017/3/17 22:34, Konrad Rzeszutek Wilk wrote:
> On Thu, Mar 16, 2017 at 05:53:38PM +0800, Wei Chen wrote:
>> This patch is based on the implementation of ARM64, it introduces
>> alternative runtime patching to ARM32. This allows to patch assembly
>> instruction at runtime to either fix hardware bugs or optimize for
>> certain hardware features on ARM32 platform.
>>
>> Xen hypervisor is using ARM execution state only on ARM32 platform,
>> Thumb is not used. So, the Thumb only branch instructions (CBZ, CBNZ,
>> TBB and TBH) are not considered in alternatives.
>>
>> The left ARM32 branch instructions are BX, BLX, BL and B. The
>> instruction BX is taking a register in parameter, so we don't need to
>> rewrite it. The instructions BLX, BL and B are using the similar
>> encoding for the offset and will avoid specific case when extracting
>> and updating the offset.
>>
>> In this patch, we include alternative.h header file to livepatch.c
>> directly for ARM32 compilation issues. When the alternative patching
>> config is enabled, the livepatch.c will use the alternative functions.
>> In this case, we should include the alternative header file to this
>> file. But for ARM64, it does not include this header file directly.
>> It includes this header file indirectly through:
>> sched.h->domain.h->page.h->alternative.h.
>> But, unfortunately, the page.h of ARM32 doesn't include alternative.h,
>> and we don't have the reason to include it to ARM32 page.h now. So we
>> have to include the alternative.h directly in livepatch.c.
>
> OK, thanks for the explanation.
>
>
> Could you also confirm that the test-cases for livepatching
> does compile for you?
>
> make -C xen tests
>
> should do it (specifically I am curious if xen_hello_world_func.c
> compiles fine).
>

Yes, the test-cases for livepatching can compile successfully.
I paste the full compiling log below:


arm32@P300:~/X32/Xen32$ make -C xen tests
make: Entering directory '/home/arm32/X32/Xen32/xen'
make -f Rules.mk _tests
make[1]: Entering directory '/home/arm32/X32/Xen32/xen'
make -f /home/arm32/X32/Xen32/xen/Rules.mk -C test tests
make[2]: Entering directory '/home/arm32/X32/Xen32/xen/test'
make -f /home/arm32/X32/Xen32/xen/Rules.mk -C livepatch livepatch
make[3]: Entering directory '/home/arm32/X32/Xen32/xen/test/livepatch'
arm-linux-gnueabihf-gcc -marm -DBUILD_ID -fno-strict-aliasing -std=gnu99 
-Wall -Wstrict-prototypes -Wdeclaration-after-statement 
-Wno-unused-but-set-variable -Wno-unused-local-typedefs   -O1 -nostdinc 
-fno-builtin -fno-common -Werror -Wredundant-decls -Wno-pointer-arith 
-pipe -g -D__XEN__ -include 
/home/arm32/X32/Xen32/xen/include/xen/config.h 
'-D__OBJECT_FILE__="xen_hello_world_func.o"' -Wa,--strip-local-absolute 
-fno-omit-frame-pointer -MMD -MF ./.xen_hello_world_func.o.d 
-msoft-float -mcpu=cortex-a15 -DCONFIG_EARLY_PRINTK 
-DEARLY_PRINTK_INC=\"debug-pl011.inc\" -DEARLY_PRINTK_BAUD= 
-DEARLY_UART_BASE_ADDRESS=0x1c090000 -DEARLY_UART_REG_SHIFT= 
-I/home/arm32/X32/Xen32/xen/include -fno-stack-protector -fno-exceptions 
-Wnested-externs -DGCC_HAS_VISIBILITY_ATTRIBUTE -marm -DBUILD_ID 
-fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes 
-Wdeclaration-after-statement -Wno-unused-but-set-variable 
-Wno-unused-local-typedefs   -c xen_hello_world_func.c -o 
xen_hello_world_func.o
(set -e; \
  echo "#define NEW_CODE_SZ 0x00000020"; \
  echo "#define MINOR_VERSION_SZ 0x00000018"; \
  echo "#define MINOR_VERSION_ADDR 0x0023e580"; \
  echo "#define OLD_CODE_SZ 0x0000001c") > config.h
arm-linux-gnueabihf-gcc -marm -DBUILD_ID -fno-strict-aliasing -std=gnu99 
-Wall -Wstrict-prototypes -Wdeclaration-after-statement 
-Wno-unused-but-set-variable -Wno-unused-local-typedefs   -O1 -nostdinc 
-fno-builtin -fno-common -Werror -Wredundant-decls -Wno-pointer-arith 
-pipe -g -D__XEN__ -include 
/home/arm32/X32/Xen32/xen/include/xen/config.h 
'-D__OBJECT_FILE__="xen_hello_world.o"' -Wa,--strip-local-absolute 
-fno-omit-frame-pointer -MMD -MF ./.xen_hello_world.o.d -msoft-float 
-mcpu=cortex-a15 -DCONFIG_EARLY_PRINTK 
-DEARLY_PRINTK_INC=\"debug-pl011.inc\" -DEARLY_PRINTK_BAUD= 
-DEARLY_UART_BASE_ADDRESS=0x1c090000 -DEARLY_UART_REG_SHIFT= 
-I/home/arm32/X32/Xen32/xen/include -fno-stack-protector -fno-exceptions 
-Wnested-externs -DGCC_HAS_VISIBILITY_ATTRIBUTE -marm -DBUILD_ID 
-fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes 
-Wdeclaration-after-statement -Wno-unused-but-set-variable 
-Wno-unused-local-typedefs   -c xen_hello_world.c -o xen_hello_world.o
arm-linux-gnueabihf-objcopy -O binary --only-section=.note.gnu.build-id 
/home/arm32/X32/Xen32/xen/xen-syms note.o.bin
arm-linux-gnueabihf-objcopy -I binary -O elf32-littlearm -B arm \
 
--rename-section=.data=.livepatch.depends,alloc,load,readonly,data,contents 
-S note.o.bin note.o
rm -f note.o.bin
arm-linux-gnueabihf-ld    -EL -EL     --build-id=sha1 -r -o 
xen_hello_world.livepatch xen_hello_world_func.o xen_hello_world.o note.o
arm-linux-gnueabihf-gcc -marm -DBUILD_ID -fno-strict-aliasing -std=gnu99 
-Wall -Wstrict-prototypes -Wdeclaration-after-statement 
-Wno-unused-but-set-variable -Wno-unused-local-typedefs   -O1 -nostdinc 
-fno-builtin -fno-common -Werror -Wredundant-decls -Wno-pointer-arith 
-pipe -g -D__XEN__ -include 
/home/arm32/X32/Xen32/xen/include/xen/config.h 
'-D__OBJECT_FILE__="xen_bye_world_func.o"' -Wa,--strip-local-absolute 
-fno-omit-frame-pointer -MMD -MF ./.xen_bye_world_func.o.d -msoft-float 
-mcpu=cortex-a15 -DCONFIG_EARLY_PRINTK 
-DEARLY_PRINTK_INC=\"debug-pl011.inc\" -DEARLY_PRINTK_BAUD= 
-DEARLY_UART_BASE_ADDRESS=0x1c090000 -DEARLY_UART_REG_SHIFT= 
-I/home/arm32/X32/Xen32/xen/include -fno-stack-protector -fno-exceptions 
-Wnested-externs -DGCC_HAS_VISIBILITY_ATTRIBUTE -marm -DBUILD_ID 
-fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes 
-Wdeclaration-after-statement -Wno-unused-but-set-variable 
-Wno-unused-local-typedefs   -c xen_bye_world_func.c -o xen_bye_world_func.o
arm-linux-gnueabihf-gcc -marm -DBUILD_ID -fno-strict-aliasing -std=gnu99 
-Wall -Wstrict-prototypes -Wdeclaration-after-statement 
-Wno-unused-but-set-variable -Wno-unused-local-typedefs   -O1 -nostdinc 
-fno-builtin -fno-common -Werror -Wredundant-decls -Wno-pointer-arith 
-pipe -g -D__XEN__ -include 
/home/arm32/X32/Xen32/xen/include/xen/config.h 
'-D__OBJECT_FILE__="xen_bye_world.o"' -Wa,--strip-local-absolute 
-fno-omit-frame-pointer -MMD -MF ./.xen_bye_world.o.d -msoft-float 
-mcpu=cortex-a15 -DCONFIG_EARLY_PRINTK 
-DEARLY_PRINTK_INC=\"debug-pl011.inc\" -DEARLY_PRINTK_BAUD= 
-DEARLY_UART_BASE_ADDRESS=0x1c090000 -DEARLY_UART_REG_SHIFT= 
-I/home/arm32/X32/Xen32/xen/include -fno-stack-protector -fno-exceptions 
-Wnested-externs -DGCC_HAS_VISIBILITY_ATTRIBUTE -marm -DBUILD_ID 
-fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes 
-Wdeclaration-after-statement -Wno-unused-but-set-variable 
-Wno-unused-local-typedefs   -c xen_bye_world.c -o xen_bye_world.o
arm-linux-gnueabihf-objcopy -O binary --only-section=.note.gnu.build-id 
xen_hello_world.livepatch hello_world_note.o.bin
arm-linux-gnueabihf-objcopy -I binary -O elf32-littlearm -B arm \
 
--rename-section=.data=.livepatch.depends,alloc,load,readonly,data,contents 
-S hello_world_note.o.bin hello_world_note.o
rm -f hello_world_note.o.bin
arm-linux-gnueabihf-ld    -EL -EL     --build-id=sha1 -r -o 
xen_bye_world.livepatch xen_bye_world_func.o xen_bye_world.o 
hello_world_note.o
arm-linux-gnueabihf-gcc -marm -DBUILD_ID -fno-strict-aliasing -std=gnu99 
-Wall -Wstrict-prototypes -Wdeclaration-after-statement 
-Wno-unused-but-set-variable -Wno-unused-local-typedefs   -O1 -nostdinc 
-fno-builtin -fno-common -Werror -Wredundant-decls -Wno-pointer-arith 
-pipe -g -D__XEN__ -include 
/home/arm32/X32/Xen32/xen/include/xen/config.h 
'-D__OBJECT_FILE__="xen_replace_world_func.o"' 
-Wa,--strip-local-absolute -fno-omit-frame-pointer -MMD -MF 
./.xen_replace_world_func.o.d -msoft-float -mcpu=cortex-a15 
-DCONFIG_EARLY_PRINTK -DEARLY_PRINTK_INC=\"debug-pl011.inc\" 
-DEARLY_PRINTK_BAUD= -DEARLY_UART_BASE_ADDRESS=0x1c090000 
-DEARLY_UART_REG_SHIFT= -I/home/arm32/X32/Xen32/xen/include 
-fno-stack-protector -fno-exceptions -Wnested-externs 
-DGCC_HAS_VISIBILITY_ATTRIBUTE -marm -DBUILD_ID -fno-strict-aliasing 
-std=gnu99 -Wall -Wstrict-prototypes -Wdeclaration-after-statement 
-Wno-unused-but-set-variable -Wno-unused-local-typedefs   -c 
xen_replace_world_func.c -o xen_replace_world_func.o
arm-linux-gnueabihf-gcc -marm -DBUILD_ID -fno-strict-aliasing -std=gnu99 
-Wall -Wstrict-prototypes -Wdeclaration-after-statement 
-Wno-unused-but-set-variable -Wno-unused-local-typedefs   -O1 -nostdinc 
-fno-builtin -fno-common -Werror -Wredundant-decls -Wno-pointer-arith 
-pipe -g -D__XEN__ -include 
/home/arm32/X32/Xen32/xen/include/xen/config.h 
'-D__OBJECT_FILE__="xen_replace_world.o"' -Wa,--strip-local-absolute 
-fno-omit-frame-pointer -MMD -MF ./.xen_replace_world.o.d -msoft-float 
-mcpu=cortex-a15 -DCONFIG_EARLY_PRINTK 
-DEARLY_PRINTK_INC=\"debug-pl011.inc\" -DEARLY_PRINTK_BAUD= 
-DEARLY_UART_BASE_ADDRESS=0x1c090000 -DEARLY_UART_REG_SHIFT= 
-I/home/arm32/X32/Xen32/xen/include -fno-stack-protector -fno-exceptions 
-Wnested-externs -DGCC_HAS_VISIBILITY_ATTRIBUTE -marm -DBUILD_ID 
-fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes 
-Wdeclaration-after-statement -Wno-unused-but-set-variable 
-Wno-unused-local-typedefs   -c xen_replace_world.c -o xen_replace_world.o
arm-linux-gnueabihf-ld    -EL -EL     --build-id=sha1 -r -o 
xen_replace_world.livepatch xen_replace_world_func.o xen_replace_world.o 
note.o
arm-linux-gnueabihf-gcc -marm -DBUILD_ID -fno-strict-aliasing -std=gnu99 
-Wall -Wstrict-prototypes -Wdeclaration-after-statement 
-Wno-unused-but-set-variable -Wno-unused-local-typedefs   -O1 -nostdinc 
-fno-builtin -fno-common -Werror -Wredundant-decls -Wno-pointer-arith 
-pipe -g -D__XEN__ -include 
/home/arm32/X32/Xen32/xen/include/xen/config.h 
'-D__OBJECT_FILE__="xen_nop.o"' -Wa,--strip-local-absolute 
-fno-omit-frame-pointer -MMD -MF ./.xen_nop.o.d -msoft-float 
-mcpu=cortex-a15 -DCONFIG_EARLY_PRINTK 
-DEARLY_PRINTK_INC=\"debug-pl011.inc\" -DEARLY_PRINTK_BAUD= 
-DEARLY_UART_BASE_ADDRESS=0x1c090000 -DEARLY_UART_REG_SHIFT= 
-I/home/arm32/X32/Xen32/xen/include -fno-stack-protector -fno-exceptions 
-Wnested-externs -DGCC_HAS_VISIBILITY_ATTRIBUTE -marm -DBUILD_ID 
-fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes 
-Wdeclaration-after-statement -Wno-unused-but-set-variable 
-Wno-unused-local-typedefs   -c xen_nop.c -o xen_nop.o
arm-linux-gnueabihf-ld    -EL -EL     --build-id=sha1 -r -o 
xen_nop.livepatch xen_nop.o note.o
make[3]: Leaving directory '/home/arm32/X32/Xen32/xen/test/livepatch'
make[2]: Leaving directory '/home/arm32/X32/Xen32/xen/test'
make[1]: Leaving directory '/home/arm32/X32/Xen32/xen'
make: Leaving directory '/home/arm32/X32/Xen32/xen'


-- 
Regards,
Wei Chen

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.