Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932479AbbFCTDH (ORCPT ); Wed, 3 Jun 2015 15:03:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51976 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754051AbbFCTC5 (ORCPT ); Wed, 3 Jun 2015 15:02:57 -0400 Date: Wed, 3 Jun 2015 21:02:53 +0200 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: Paolo Bonzini Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, guangrong.xiao@linux.intel.com, bdas@redhat.com Subject: Re: [PATCH v2 06/13] KVM: x86: save/load state on SMM switch Message-ID: <20150603190253.GA13488@potion.brq.redhat.com> References: <1432746314-50196-1-git-send-email-pbonzini@redhat.com> <1432746314-50196-7-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1432746314-50196-7-git-send-email-pbonzini@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1863 Lines: 54 2015-05-27 19:05+0200, Paolo Bonzini: > The big ugly one. This patch adds support for switching in and out of > system management mode, respectively upon receiving KVM_REQ_SMI and upon > executing a RSM instruction. Both 32- and 64-bit formats are supported > for the SMM state save area. > > Signed-off-by: Paolo Bonzini > --- > RFC->v1: shift access rights left by 8 for 32-bit format > move tracepoint to kvm_set_hflags > fix NMI handling > --- > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > static void process_smi(struct kvm_vcpu *vcpu) > { > + struct kvm_segment cs, ds; > + char buf[512]; > + u32 cr0; > + int r; > + > if (is_smm(vcpu)) { > vcpu->arch.smi_pending = true; > return; > } > > - printk_once(KERN_DEBUG "Ignoring guest SMI\n"); > + trace_kvm_enter_smm(vcpu->vcpu_id, vcpu->arch.smbase, true); > + vcpu->arch.hflags |= HF_SMM_MASK; > + memset(buf, 0, 512); > + if (guest_cpuid_has_longmode(vcpu)) > + process_smi_save_state_64(vcpu, buf); > + else > + process_smi_save_state_32(vcpu, buf); > + > + r = kvm_write_guest(vcpu->kvm, vcpu->arch.smbase + 0xfe00, buf, sizeof(buf)); The state is saved in SMRAM, but we are accessing it using the non-SMM address space ... how did it pass testing? (Restore is using SMM address space, so I'm guessing that the mapping from QEMU wasn't really utilizing two separate address spaces.) > + if (r < 0) > + return; And if we fail to write it, is there other option than throwing an error to userspace? (Unset HF_SMM_MASK and pretend that nothing happened doesn't find much support in docs.) Thanks. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/