Hi Sean, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on kvm/linux-next] [also build test WARNING on v5.1-rc3] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Sean-Christopherson/KVM-x86-clear-HF_SMM_MASK-before-loading-state/20190403-053443 base: https://git.kernel.org/pub/scm/virt/kvm/kvm.git linux-next config: i386-randconfig-b0-04040009 (attached as .config) compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4 reproduce: # save the attached .config to linux build tree make ARCH=i386 All warnings (new ones prefixed by >>): arch/x86/kvm/emulate.c: In function 'rsm_load_state_64': >> arch/x86/kvm/emulate.c:2506:23: warning: iteration 9u invokes undefined behavior [-Waggressive-loop-optimizations] *reg_write(ctxt, i) = GET_SMSTATE(u64, smstate, 0x7ff8 - i * 8); ^ arch/x86/kvm/emulate.c:2505:2: note: containing loop for (i = 0; i < 16; i++) ^ vim +2506 arch/x86/kvm/emulate.c 2494 2495 static int rsm_load_state_64(struct x86_emulate_ctxt *ctxt, 2496 const char *smstate) 2497 { 2498 struct desc_struct desc; 2499 struct desc_ptr dt; 2500 u64 val, cr0, cr3, cr4; 2501 u32 base3; 2502 u16 selector; 2503 int i, r; 2504 2505 for (i = 0; i < 16; i++) > 2506 *reg_write(ctxt, i) = GET_SMSTATE(u64, smstate, 0x7ff8 - i * 8); 2507 2508 ctxt->_eip = GET_SMSTATE(u64, smstate, 0x7f78); 2509 ctxt->eflags = GET_SMSTATE(u32, smstate, 0x7f70) | X86_EFLAGS_FIXED; 2510 2511 val = GET_SMSTATE(u32, smstate, 0x7f68); 2512 ctxt->ops->set_dr(ctxt, 6, (val & DR6_VOLATILE) | DR6_FIXED_1); 2513 val = GET_SMSTATE(u32, smstate, 0x7f60); 2514 ctxt->ops->set_dr(ctxt, 7, (val & DR7_VOLATILE) | DR7_FIXED_1); 2515 2516 cr0 = GET_SMSTATE(u64, smstate, 0x7f58); 2517 cr3 = GET_SMSTATE(u64, smstate, 0x7f50); 2518 cr4 = GET_SMSTATE(u64, smstate, 0x7f48); 2519 ctxt->ops->set_smbase(ctxt, GET_SMSTATE(u32, smstate, 0x7f00)); 2520 val = GET_SMSTATE(u64, smstate, 0x7ed0); 2521 ctxt->ops->set_msr(ctxt, MSR_EFER, val & ~EFER_LMA); 2522 2523 selector = GET_SMSTATE(u32, smstate, 0x7e90); 2524 rsm_set_desc_flags(&desc, GET_SMSTATE(u32, smstate, 0x7e92) << 8); 2525 set_desc_limit(&desc, GET_SMSTATE(u32, smstate, 0x7e94)); 2526 set_desc_base(&desc, GET_SMSTATE(u32, smstate, 0x7e98)); 2527 base3 = GET_SMSTATE(u32, smstate, 0x7e9c); 2528 ctxt->ops->set_segment(ctxt, selector, &desc, base3, VCPU_SREG_TR); 2529 2530 dt.size = GET_SMSTATE(u32, smstate, 0x7e84); 2531 dt.address = GET_SMSTATE(u64, smstate, 0x7e88); 2532 ctxt->ops->set_idt(ctxt, &dt); 2533 2534 selector = GET_SMSTATE(u32, smstate, 0x7e70); 2535 rsm_set_desc_flags(&desc, GET_SMSTATE(u32, smstate, 0x7e72) << 8); 2536 set_desc_limit(&desc, GET_SMSTATE(u32, smstate, 0x7e74)); 2537 set_desc_base(&desc, GET_SMSTATE(u32, smstate, 0x7e78)); 2538 base3 = GET_SMSTATE(u32, smstate, 0x7e7c); 2539 ctxt->ops->set_segment(ctxt, selector, &desc, base3, VCPU_SREG_LDTR); 2540 2541 dt.size = GET_SMSTATE(u32, smstate, 0x7e64); 2542 dt.address = GET_SMSTATE(u64, smstate, 0x7e68); 2543 ctxt->ops->set_gdt(ctxt, &dt); 2544 2545 r = rsm_enter_protected_mode(ctxt, cr0, cr3, cr4); 2546 if (r != X86EMUL_CONTINUE) 2547 return r; 2548 2549 for (i = 0; i < 6; i++) { 2550 r = rsm_load_seg_64(ctxt, smstate, i); 2551 if (r != X86EMUL_CONTINUE) 2552 return r; 2553 } 2554 2555 return X86EMUL_CONTINUE; 2556 } 2557 --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation
Attachment:
.config.gz
Description: application/gzip