x86/vmx: Shrink TASK_SWITCH's hvm_task_switch_reason reasons[]
PATCH 1/1 x86/vmx: Shrink TASK_SWITCH's hvm_task_switch_reason reasons[]
No need to use 4-byte integers to store two bits of information.
---
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Jun Nakajima <[email protected]>
CC: Kevin Tian <[email protected]>
--- xen/arch/x86/hvm/vmx/vmx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/hvm/vmx/vmx.c +1 -1
@@ -3978,7 +3978,7 @@ void vmx_vmexit_handler(struct cpu_user_regs *regs)vmx_update_cpu_exec_control (v);break ;case EXIT_REASON_TASK_SWITCH : { -static const enum hvm_task_switch_reason reasons[] = { +static const int8_t reasons[] = { TSW_call_or_int, TSW_iret, TSW_jmp, TSW_call_or_int };unsigned int inst_len, source;
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 3 lines · Andrew Cooper
No need to use 4-byte integers to store two bits of information.
Signed-off-by Andrew Cooper <[email protected]>
In principle
But ...
xen/arch/x86/hvm/vmx/vmx.c void vmx_vmexit_handler(struct cpu_user_regs *regs) · line 3983
Quoted 10 lines
xen/arch/x86/hvm/vmx/vmx.c +1
-1@@ -3978,7 +3978,7 @@ void vmx_vmexit_handler(struct cpu_user_regs *regs)vmx_update_cpu_exec_control (v);break ;case EXIT_REASON_TASK_SWITCH : { -static const enum hvm_task_switch_reason reasons[] = { +static const int8_t reasons[] = { TSW_call_or_int, TSW_iret, TSW_jmp, TSW_call_or_int };
... given our general preference of unsigned types when values can't become negative, why not uint8_t?
As an aside, elsewhere I saw people starting to convert code because apparently gcc 10 will warn about enum type mismatches. I didn't investigate yet whether that's just for enum -> enum conversions, or also for enum <- / -> integer ones. Of course it wouldn't be the end of the world if we had to revert the change above; did you consider the alternative of making the enum a __packed one (which would avoid potential issues like the one named)?
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 6 lines
From: Andrew Cooper <[email protected]>
Sent: Tuesday, January 7, 2020 8:25 PMNo need to use 4-byte integers to store two bits of information.
Signed-off-by Andrew Cooper <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel