Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751947AbbFDGPI (ORCPT ); Thu, 4 Jun 2015 02:15:08 -0400 Received: from mail-wg0-f49.google.com ([74.125.82.49]:33660 "EHLO mail-wg0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750936AbbFDGO7 (ORCPT ); Thu, 4 Jun 2015 02:14:59 -0400 Message-ID: <556FECD4.3010507@redhat.com> Date: Thu, 04 Jun 2015 08:14:44 +0200 From: Paolo Bonzini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= 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 References: <1432746314-50196-1-git-send-email-pbonzini@redhat.com> <1432746314-50196-7-git-send-email-pbonzini@redhat.com> <20150603190253.GA13488@potion.brq.redhat.com> In-Reply-To: <20150603190253.GA13488@potion.brq.redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1666 Lines: 48 On 03/06/2015 21:02, Radim Krčmář wrote: >> + 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.) At this point of the series there are no separate address spaces yet. Patch 10 then changes it everywhere: @@ -6558,7 +6558,7 @@ static void process_smi(struct kvm_vcpu *vcpu) else process_smi_save_state_32(vcpu, buf); - r = kvm_write_guest(vcpu->kvm, vcpu->arch.smbase + 0xfe00, buf, sizeof(buf)); + r = kvm_vcpu_write_guest(vcpu, vcpu->arch.smbase + 0xfe00, buf, sizeof(buf)); if (r < 0) return; Why did I order it this way? Because it is already possible to test this code with the default SMBASE of 0x30000, and it is already possible to run the full firmware if you hack it not to close SMRAM (for this I used q35's high SMRAM). It is not possible to test the code partially if you first add the two address spaces, and only implement the world switch second. Thanks, Paolo >> + 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/