From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6DDE2C47247 for ; Tue, 5 May 2020 06:27:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 58C5D208DB for ; Tue, 5 May 2020 06:27:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727973AbgEEG1c (ORCPT ); Tue, 5 May 2020 02:27:32 -0400 Received: from mga04.intel.com ([192.55.52.120]:27813 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725768AbgEEG1c (ORCPT ); Tue, 5 May 2020 02:27:32 -0400 IronPort-SDR: SpD10RFiEwclIahYwZ633tbtBa9kY7VZ/+M68iD3KCtAxrNQI43rrOfRUmuQ5BHf45O28D2mfs yEA7t9e/2yIw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 May 2020 23:27:31 -0700 IronPort-SDR: vl+njINXLuyLK6eoYh6PA0UoEuhh4q2ND00lS7rR9iXyRho/etQNhH0cZQ8oSrbRv49NVwtCXC uTl0cmf6bn6A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,354,1583222400"; d="scan'208";a="460929127" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.152]) by fmsmga005.fm.intel.com with ESMTP; 04 May 2020 23:27:31 -0700 Date: Mon, 4 May 2020 23:27:31 -0700 From: Sean Christopherson To: Greg Kroah-Hartman Cc: stable@vger.kernel.org, Ben Hutchings , Sasha Levin , Paolo Bonzini , linux-kernel@vger.kernel.org, Tobias Urdin Subject: Re: [PATCH 4.19 STABLE 2/2] KVM: VMX: Mark RCX, RDX and RSI as clobbered in vmx_vcpu_run()'s asm blob Message-ID: <20200505062731.GA17313@linux.intel.com> References: <20200505012348.17099-1-sean.j.christopherson@intel.com> <20200505012348.17099-3-sean.j.christopherson@intel.com> <20200505061502.GA3874653@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200505061502.GA3874653@kroah.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 05, 2020 at 08:15:02AM +0200, Greg Kroah-Hartman wrote: > On Mon, May 04, 2020 at 06:23:48PM -0700, Sean Christopherson wrote: > > Save RCX, RDX and RSI to fake outputs to coerce the compiler into > > treating them as clobbered. RCX in particular is likely to be reused by > > the compiler to dereference the 'struct vcpu_vmx' pointer, which will > > result in a null pointer dereference now that RCX is zeroed by the asm > > blob. > > > > Add ASM_CALL_CONSTRAINT to fudge around an issue where > > during modpost can't find vmx_return when specifying output constraints. > > > > Reported-by: Tobias Urdin > > Fixes: b4be98039a92 ("KVM: VMX: Zero out *all* general purpose registers after VM-Exit") > > Signed-off-by: Sean Christopherson > > --- > > arch/x86/kvm/vmx.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c > > index 5b06a98ffd4c..54c8b4dc750d 100644 > > --- a/arch/x86/kvm/vmx.c > > +++ b/arch/x86/kvm/vmx.c > > @@ -10882,7 +10882,8 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu) > > ".global vmx_return \n\t" > > "vmx_return: " _ASM_PTR " 2b \n\t" > > ".popsection" > > - : : "c"(vmx), "d"((unsigned long)HOST_RSP), "S"(evmcs_rsp), > > + : ASM_CALL_CONSTRAINT, "=c"((int){0}), "=d"((int){0}), "=S"((int){0}) > > + : "c"(vmx), "d"((unsigned long)HOST_RSP), "S"(evmcs_rsp), > > [launched]"i"(offsetof(struct vcpu_vmx, __launched)), > > [fail]"i"(offsetof(struct vcpu_vmx, fail)), > > [host_rsp]"i"(offsetof(struct vcpu_vmx, host_rsp)), > > -- > > 2.26.0 > > > > What is the git commit id of this patch in Linus's tree? There is none. In upstream at the time of the offending commit (b4be98039a92 in 4.19, 0e0ab73c9a024 upstream), the inline asm blob had previously been moved to a dedicated helper, __vmx_vcpu_run(), that was intentionally put into a separate compilation unit, i.e. consuming the clobbered register was effectively impossible because %rcx is volatile and __vmx_vcpu_run() couldn't itself be inlined. To make things more confusing, the inline asm blob got moved into a proper asm subroutine shortly thereafter. Things really start to diverge from current upstream right around the time of this commit.