Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp709036pxb; Thu, 9 Sep 2021 10:10:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3bHHrsQ/tIEtwAmaLjuxyB7Y58dJPet8yC4JCf5m7iRkkBApWjVUSte/BZat/CFmsLdw+ X-Received: by 2002:a92:690b:: with SMTP id e11mr2946646ilc.321.1631207438000; Thu, 09 Sep 2021 10:10:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631207437; cv=none; d=google.com; s=arc-20160816; b=IWX9DT0yt7cF0Zt4N857+ugzkp6AVdNJRVjuwjSbJUEgvpEn5iX4optkFueqwHLa+Y MaBir58pCQCspKarYU3ihH9JGX/ozgGZO6bigXPreTgUeVR3/c044vsGy6q32PpDtf5Y 3+xAbqc2q9j4TWQFq0NFqCJFA5+rjlgfxPveP0/RJeNUNoIz9m1+1/hdMdc3ikT/6JR8 /fNdDBmm6cpvSWY2dkvM4GOTBXJj/4Vp7ZiniqaUwdJ0fqm9FE2AjdlwlOgdxe/EJ3uL UfU9iSFtBAjOqoaYjO0IqDqHnsxYEpNNrDhGuAWHud2xi0AiY+3bXrC1Anaf4wvqQVuL hP/g== 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=aBtM+Vc7Pdk2KbXitmQqbb8Smj1Sm+602q1syMUfkco=; b=p4aeJmaFhlhF1m30kbXNlxu6Vbxs/ZFLa9E3sXVVO5VxG2CUAr2JSMHFBW8eypwFiG lRV+MZ2IQW8AHeJpdDSOC6h89oBmhif3a3d6WEcgFBl47EZxkA9jqwj+tPeEbOBW/lKA 0svk55Pssb12H859RC0+UsEav46UMJ5WsIqPIiYuut0wpffebCpOvK+/M2/FYNuGBDyu FFJijAkHzFjcd0nnhQKp2DC30E7AxMHjOH3wb3nZed5a3M7kKkR0YPdFxnpbfRwl6JDc JLmzEvdKKR8WhNLk2uCxI2vVfGvpNb/Bv/OT1nJ9Rfq6XAwH4eUNV3ShjJp7K152HSwn nL4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=k43+wP4X; 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 z26si1987532ioc.55.2021.09.09.10.10.16; Thu, 09 Sep 2021 10:10:37 -0700 (PDT) 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=20210112 header.b=k43+wP4X; 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 S240804AbhIIRK0 (ORCPT + 99 others); Thu, 9 Sep 2021 13:10:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237084AbhIIRKZ (ORCPT ); Thu, 9 Sep 2021 13:10:25 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CF1AC061574 for ; Thu, 9 Sep 2021 10:09:16 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id m21-20020a17090a859500b00197688449c4so1960240pjn.0 for ; Thu, 09 Sep 2021 10:09:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=aBtM+Vc7Pdk2KbXitmQqbb8Smj1Sm+602q1syMUfkco=; b=k43+wP4XjElxHdhGoIl3EArpqrrKP9efEUsSpzl8yfxIKXgG2r01TrRNEloYN/070s psSDinINGrXnE/sGefyEmidxLuIXLQWbvcuMJTleE/BiRdRurVyA7poDYPnpPuhy/FtY loa/sRj7PbmXt9ODqmyRANNK+nidaLFfsOQ0jKtfL4y1dDst2DP5nOZv6y19oDZskDEI UjqU0mnTOU3cEdpxzR+p3dpujVrpYIlpaQGOFiM6LwyTtlF+8BvL8Rqzo4CKcE6adPwg TYkjbrDih81xcxJNySwqxIcs4foWtqeNzUrEqcwPZDN9/h/evLRd6AccdLMQIwN2JahQ JSzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=aBtM+Vc7Pdk2KbXitmQqbb8Smj1Sm+602q1syMUfkco=; b=Hym3zva3z7h8w1iRF/asQRWaXO6vEsWUNOJFdiJg1VrXtKqUxpirBP2IaGIY9ZltG5 MIhxlv7mOI8oX6rzNmDN7VIfodahsvDIlj7AVVswLtUfGxgskXKkm+//Q1p9KczpGY/u fmdgERdo6zRDmM/pAqx+R64gz4lBPwr+hK9H3zS6dJjnLeVFKfI+cR58HbQlSXUYzQn3 u66YrHmzMtYIeIdyRPYzU+CK4oeVfiaznAS2MZlmlTCfN9Etw6dZUQFE/n3wyNOOLfcI NFMxQHgC4f/cQVLMEW2YkpEFnAXqMUnAgBaISI7Ll9SKzzrbrW0oFKrfxDlKX9pKMyq1 oRKQ== X-Gm-Message-State: AOAM5328QOq1g6WbkuNknUc4q5oNvzxXNpqcgVy8L7CnTpbhapDM8DvH j7WCHThGOfVCKiIj9IoSWO8/+A== X-Received: by 2002:a17:902:bf07:b0:138:e32d:9f2e with SMTP id bi7-20020a170902bf0700b00138e32d9f2emr3524138plb.59.1631207355415; Thu, 09 Sep 2021 10:09:15 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id o10sm2854670pjo.47.2021.09.09.10.09.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Sep 2021 10:09:14 -0700 (PDT) Date: Thu, 9 Sep 2021 17:09:11 +0000 From: Sean Christopherson To: Yu Zhang Cc: Hou Wenlong , kvm@vger.kernel.org, Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , "H. Peter Anvin" , Jan Kiszka , Avi Kivity , "open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)" Subject: Re: [PATCH v2 1/3] kvm: x86: Introduce hypercall x86 ops for handling hypercall not in cpl0 Message-ID: References: <04a337801ad5aaa54144dc57df8ee2fc32bc9c4e.1631188011.git.houwenlong93@linux.alibaba.com> <20210909163901.2vvozmkuxjcgabs5@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210909163901.2vvozmkuxjcgabs5@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 10, 2021, Yu Zhang wrote: > On Thu, Sep 09, 2021 at 07:55:23PM +0800, Hou Wenlong wrote: > > Per Intel's SDM, use vmcall instruction in non VMX operation for cpl3 > > it should trigger a #UD. And in VMX root operation, it should > > Are you sure? IIRC, vmcall will always cause VM exit as long as CPU > is in non-root mode(regardless the CPL). Correct, VMCALL unconditionally causes VM-Exit in non-root mode, but Hou is referring to the first fault condition of "non VMX operation". The intent of the patch is to emulate hardware behavior for CPL>0: if L1 is not in VMX operation, a.k.a. not post-VMXON, then #UD, else #GP (because VMCALL #GPs at CPL>0 in VMX root). On one hand, I agree with Hou's logic; injecting #UD/#GP is architecturally correct if KVM is emulating a bare metal environment for the guest. On the other hand, that contradicts with KVM _not_ injecting #UD for guest CPL0, i.e. KVM is clearly not emulating a bare metal environment. In the end, this would represent an ABI change for guest CPL>0. While it's highly unlikely that such a change would cause problems, maintaining the current behavior is the safe option unless there's strong motivation for changing the guest ABI. And injecting #UD/#GP would also mean KVM would again have to change its ABI if there is a future hypercall KVM wants to allow at CPL>0. Again, that's unlikely, but again I don't see sufficient justification.