Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp232960pxu; Tue, 5 Jan 2021 09:23:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJxcAkNteicOFUxKFnJqQbNnZZGboA+GjYqJYFO+utntyl5uRLaj8jSsmOaMH76G5EDwafYJ X-Received: by 2002:a17:906:3999:: with SMTP id h25mr198743eje.146.1609867404528; Tue, 05 Jan 2021 09:23:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609867404; cv=none; d=google.com; s=arc-20160816; b=YOCwRpLf2zh1Wcup2zdprad3gpgFLVIRU62O8x+ulPaAzbVWuJSBtn1N0Z+WHxbSzk PbIAXdm8wvkmS2HITzzMjrmiVCpOnoxd8wrCEbyOqvbDMFRv4KHPEMgEmGnfUrWY0yaP FXBy5yRhXJ99xbl0428cxdDgj/iO5+p4j6Pb2s2Zjx5he76w0MhRj78QWp2wTj5CQuTc lGGgYKudxZKh+7NGTqKh+hK7aCaxLWawlyiesn/BQPU1zsl/XPDwKPowZk+AsutAoTCY gJA1FF7tQMrCb9vwOKekvc4wPGFBXHT/1nBOPPRM7wU6kd5Mp8ZqgK0JJibFkLyPoWwR nwUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=1pPTiUUmwCILGPwhqjMlwzdtjWGk5FIG2OkWDCPGKCI=; b=RyeAze9Nt1eyj3Va5UESRokoO2p8SyBBpRVpQNjkgqHlIlT3Xsd99wtC68mOQk8KXK kVJlHGABFN1BxLVG0h80A+qTIm/AhkdbIkWPo4XaDhorkceQzeoTJyNBqAt40jGral+5 GuH1chRF30qEj7UDSd7UcDWuTQwnSi4TXP9mP2vdX3qmEcCNWqCIyUuCLvymOisnO9R8 jEcNzemIjFyz6YQVHGib75mglY81WxsWk79l158qO4B/u33JXsSQAXk6PkJZedvlugln A7hBjNqQW9BmM7+isnZl5hUN26UAXd7HPUp6F9rVc90fTiqr9Pj3CgziMZJ6+FfEeU5u bCXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=St40kywp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jw12si22006ejb.176.2021.01.05.09.23.00; Tue, 05 Jan 2021 09:23:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=St40kywp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730481AbhAERUw (ORCPT + 99 others); Tue, 5 Jan 2021 12:20:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726132AbhAERUv (ORCPT ); Tue, 5 Jan 2021 12:20:51 -0500 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 665FEC061795 for ; Tue, 5 Jan 2021 09:20:11 -0800 (PST) Received: by mail-pj1-x1035.google.com with SMTP id f14so12335pju.4 for ; Tue, 05 Jan 2021 09:20:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=1pPTiUUmwCILGPwhqjMlwzdtjWGk5FIG2OkWDCPGKCI=; b=St40kywpxzGWUQJd/PTqmSp7Jly2sPjPC7KB2YdngnWIp+3e+N0nbh2JSmwihXWJCR mUUSEIaD5/Sjrp0JY0tqAbfaEBzr7JfQzxJFtQ3njvG6I8mV2BoW7Co2RIzbgA7CzlxQ rIsaSONJQQTKM0qbal8BS+leW3BfFGo0FrYU5DnlXlOXDXE7IcC2eOELl16KFSSR0mfF fo6VkDbLSTUl9X6jh5OBzSspXl+2SCBX2HADmvsYAizYZ5boi3ThNvZjypkPl+lxdekC tM8d4NUFKIvYicaYOIxBDVVym8Px2ENHemIRqsbXkQJeeP5WZ8t/t11IF1oiECO8rgtn SNaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=1pPTiUUmwCILGPwhqjMlwzdtjWGk5FIG2OkWDCPGKCI=; b=bTO4ppBwc59pkEsJBagKzfxnTZF9GeaDWwlAp+SxCSP9o2gWLhBNmDe31SRs6znmVR XD6wxaqMk3X8BhUezwgaPY5Zjkb9FBV2wsPP2vB/LNSXstKyVY89HgGuGwJuVnu8OoPI YI+HGYaHrx34b+iVzJ7foxDQ0Qi0juHJsIlhjgNyly+LrhOMS8nu6hyy1RxdPfVii2he 3tcPJrBZm6035ZsB3COZbvBuJvUcsHxxYOGv3h+X3fRlgDvV+Alqzu2cwARyomNF8kh1 +7/FVWG31i+Oz8k1n4HHH59U1fW9YeD85LxQca413GTBmlhhAWQNmLc18tfDP6TpggjW GZyw== X-Gm-Message-State: AOAM533oybhES2mSnOt5MMBAvwk4hpOivmevIUdBQ5j8I6at3QP385vi 5Jga19Tltpg2dIbYJvbrUba7nw== X-Received: by 2002:a17:902:d916:b029:da:3e9e:cd7c with SMTP id c22-20020a170902d916b02900da3e9ecd7cmr330723plz.27.1609867210796; Tue, 05 Jan 2021 09:20:10 -0800 (PST) Received: from google.com ([2620:15c:f:10:1ea0:b8ff:fe73:50f5]) by smtp.gmail.com with ESMTPSA id 14sm7319pfy.55.2021.01.05.09.20.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jan 2021 09:20:10 -0800 (PST) Date: Tue, 5 Jan 2021 09:20:03 -0800 From: Sean Christopherson To: Michael Roth Cc: kvm@vger.kernel.org, Paolo Bonzini , Andy Lutomirski , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H . Peter Anvin" , linux-kernel@vger.kernel.org, Tom Lendacky Subject: Re: [PATCH v3 1/3] KVM: SVM: use vmsave/vmload for saving/restoring additional host state Message-ID: References: <20210105143749.557054-1-michael.roth@amd.com> <20210105143749.557054-2-michael.roth@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210105143749.557054-2-michael.roth@amd.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 05, 2021, Michael Roth wrote: > @@ -3703,16 +3688,9 @@ static noinstr void svm_vcpu_enter_exit(struct kvm_vcpu *vcpu, > if (sev_es_guest(svm->vcpu.kvm)) { > __svm_sev_es_vcpu_run(svm->vmcb_pa); > } else { > - __svm_vcpu_run(svm->vmcb_pa, (unsigned long *)&svm->vcpu.arch.regs); > - > -#ifdef CONFIG_X86_64 > - native_wrmsrl(MSR_GS_BASE, svm->host.gs_base); > -#else > - loadsegment(fs, svm->host.fs); > -#ifndef CONFIG_X86_32_LAZY_GS > - loadsegment(gs, svm->host.gs); > -#endif > -#endif > + __svm_vcpu_run(svm->vmcb_pa, (unsigned long *)&svm->vcpu.arch.regs, > + page_to_phys(per_cpu(svm_data, > + vcpu->cpu)->save_area)); Does this need to use __sme_page_pa()? > } > > /* ... > diff --git a/arch/x86/kvm/svm/vmenter.S b/arch/x86/kvm/svm/vmenter.S > index 6feb8c08f45a..89f4e8e7bf0e 100644 > --- a/arch/x86/kvm/svm/vmenter.S > +++ b/arch/x86/kvm/svm/vmenter.S > @@ -33,6 +33,7 @@ > * __svm_vcpu_run - Run a vCPU via a transition to SVM guest mode > * @vmcb_pa: unsigned long > * @regs: unsigned long * (to guest registers) > + * @hostsa_pa: unsigned long > */ > SYM_FUNC_START(__svm_vcpu_run) > push %_ASM_BP > @@ -47,6 +48,9 @@ SYM_FUNC_START(__svm_vcpu_run) > #endif > push %_ASM_BX > > + /* Save @hostsa_pa */ > + push %_ASM_ARG3 > + > /* Save @regs. */ > push %_ASM_ARG2 > > @@ -154,6 +158,12 @@ SYM_FUNC_START(__svm_vcpu_run) > xor %r15d, %r15d > #endif > > + /* "POP" @hostsa_pa to RAX. */ > + pop %_ASM_AX > + > + /* Restore host user state and FS/GS base */ > + vmload %_ASM_AX This VMLOAD needs the "handle fault on reboot" goo. Seeing the code, I think I'd prefer to handle this in C code, especially if Paolo takes the svm_ops.h patch[*]. Actually, I think with that patch it'd make sense to move the existing VMSAVE+VMLOAD for the guest into svm.c, too. And completely unrelated, the fault handling in svm/vmenter.S can be cleaned up a smidge to eliminate the JMPs. Paolo, what do you think about me folding these patches into my series to do the above cleanups? And maybe sending a pull request for the end result? (I'd also like to add on a patch to use the user return MSR mechanism for MSR_TSC_AUX). [*] https://lkml.kernel.org/r/20201231002702.2223707-8-seanjc@google.com > + > pop %_ASM_BX > > #ifdef CONFIG_X86_64 > -- > 2.25.1 >