Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1949615pxb; Fri, 25 Mar 2022 08:29:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx7pKHKt2lFk3Px+2e1RU8NO1zubB/OpnelTIsenjhAl28qM+54GUMJLKn2Ol+TvmM/etum X-Received: by 2002:a17:902:76c7:b0:14f:cbb1:71da with SMTP id j7-20020a17090276c700b0014fcbb171damr12087623plt.39.1648222144549; Fri, 25 Mar 2022 08:29:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648222144; cv=none; d=google.com; s=arc-20160816; b=ihJttMVNkuvJRCCqmthMOdcgKMtZy6m+Z5AE6HlXzp+d11eBOkn28JMzl9lNEBNiC8 bAfJCMJLntm+OtiJcWQLM9TWdgS1R45S9JWhtCKzxrpKi0a5fqtoiFoJhZuhzGzwNxS+ qaxpArdUN+hOOlIinudJLIYbb3nauOHRbowRTqbW44kXuLCsnbjnUiu4WyY4m5VBjC/w n6rmVE6d8RHnr5S9ycGut8f8cHO5bXl/Bpl3tldqKuFyWNXxj2v4hHXINLpXteT1etj2 h4cYxSk7jhp7KCfR+pG+UdcgjeI0aPR77vLfJgFvWYQCmxwOxWaWDaiikdmSc+ekhJju YR3Q== 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=fbhAasjsFq+DCPOkZ056UEhAK9GneQ3ssLZTa7vJBEY=; b=Ep5WydisoZLHke9TBcSN+xqGgtolWS8crXe75E3TcWlLfdRY3ZnziqrfDMYd9PGVHc hf8/mI71tDfizR0aMO8zXYmkd2/KtI0ztwgXslnwnYsSrCgoWHvSz4XGAfnIsMBH8mON Dnc18kkNVmOTqO9hrZBjOjBkh6gpfjA+eFy5A55t5mSjtACcsSS9hLfuQOM8TMULtT6Q idw3a2g9jM8CQT/n0IGwWgrB8fAC0W1/jrfO7E0LjAo6uWH/SBUlPj/fybsvPsrPTigG 4qz16OHGnK2DFqkb5u+rY0hOkrIpjpxJyG65iRXGD/iKiwcoXe0uMr9mbqaD9PyJnBUx /UUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=WBjZU6Uj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h4-20020a63b004000000b003822b0c2142si2876911pgf.279.2022.03.25.08.28.50; Fri, 25 Mar 2022 08:29:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=WBjZU6Uj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1357033AbiCYAK2 (ORCPT + 99 others); Thu, 24 Mar 2022 20:10:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357021AbiCYAKN (ORCPT ); Thu, 24 Mar 2022 20:10:13 -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 6AC43245B6 for ; Thu, 24 Mar 2022 17:08:41 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id mj15-20020a17090b368f00b001c637aa358eso10910532pjb.0 for ; Thu, 24 Mar 2022 17:08:41 -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=fbhAasjsFq+DCPOkZ056UEhAK9GneQ3ssLZTa7vJBEY=; b=WBjZU6Ujv4ue++AV8YveRa9jaY7zVtS5fTEy9wBFOzoSXFXQL57wkYaMwyfuT1L+Ni NjPPjW1f3JN/F9XwrDmNXdxHQRRYFKJ8O+dR8ZVJWBmxmB2GLLDVIAShsJ6yNdUSmNkh kzihAv4xPCKD1Lbd28mH3XxHlIsbRZxAPJ+lFN9lXJvElNPTY/o8iJ+eulmAAMhDLpFE vgIGQjWnrHBbo1FR/+j7xuO89WAufPDsS7SX0BWfCRddsz4ONVlbsj8V1GYeI7gYX2je 2drgX8beDy0dHTUBvFWdM18sZruWCT/qCDJO9eZW1a6/g+r+Ko90ndYbxrCZANwwo/TP QqPw== 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=fbhAasjsFq+DCPOkZ056UEhAK9GneQ3ssLZTa7vJBEY=; b=sNX3X2aCOUQDlGht83qMAlmGMQi+B97jYv7j0ZigvtMrljxRwguK24qX31IYJ9tw2z AJJSDbR47wHFd7tQ+yjK4SPZJEEqqdqLKIHFI70L5MKBsTIPnHPgJV5dAZt6uLCtwHes MVmU/+m7uPYWiNzzE1ybmKUAKd10TtQrtbSur7H2kD7M2rgd1sKGsiXF3PzM4wHOolal h5W+mdaCr19PnotUoyP9wsibkSz4oLbwwig+16ZFusKBerXWuc+TpsPsqIs8CL71DMtU PwiFf5d7qa9f5+PH5nn8wl03n/bmzg9I3Wjg7KcXFXpTf2oV+8AlE7JyXLLHXl+GNFk8 nceg== X-Gm-Message-State: AOAM531GLxCh1nhLxSFLPE8Ivf01sAwv//+d+JlcRhyvqBliY39XMa6+ rUTVb3pNXMIhcSl+2tqqZt4sMg== X-Received: by 2002:a17:902:f70f:b0:153:ebfe:21b3 with SMTP id h15-20020a170902f70f00b00153ebfe21b3mr8572494plo.119.1648166920531; Thu, 24 Mar 2022 17:08:40 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id q21-20020a63e215000000b00373efe2cbcbsm3501410pgh.80.2022.03.24.17.08.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Mar 2022 17:08:39 -0700 (PDT) Date: Fri, 25 Mar 2022 00:08:36 +0000 From: Sean Christopherson To: SU Hang Cc: kvm@vger.kernel.org, =?utf-8?B?6LWW5rGf5bGx?= , Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] KVM: VMX: replace 0x180 with EPT_VIOLATION_* definition Message-ID: References: <20220321094203.109546-1-darcy.sh@antgroup.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220321094203.109546-1-darcy.sh@antgroup.com> X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 21, 2022, SU Hang wrote: > Using self-expressing macro definition EPT_VIOLATION_GVA_VALIDATION > and EPT_VIOLATION_GVA_TRANSLATED instead of 0x180 > in FNAME(walk_addr_generic)(). > > Signed-off-by: SU Hang > --- > arch/x86/include/asm/vmx.h | 2 ++ > arch/x86/kvm/mmu/paging_tmpl.h | 3 ++- > 2 files changed, 4 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/include/asm/vmx.h b/arch/x86/include/asm/vmx.h > index 0ffaa3156a4e..a6789fe9b56e 100644 > --- a/arch/x86/include/asm/vmx.h > +++ b/arch/x86/include/asm/vmx.h > @@ -546,6 +546,7 @@ enum vm_entry_failure_code { > #define EPT_VIOLATION_READABLE_BIT 3 > #define EPT_VIOLATION_WRITABLE_BIT 4 > #define EPT_VIOLATION_EXECUTABLE_BIT 5 > +#define EPT_VIOLATION_GVA_VALIDATION_BIT 7 VALIDATION isn't quite right, EPT_VIOLATION_GVA_IS_VALID is more appropriate. VALIDATION makes it sound like the CPU has does some form of validation on the GVA. > #define EPT_VIOLATION_GVA_TRANSLATED_BIT 8 > #define EPT_VIOLATION_ACC_READ (1 << EPT_VIOLATION_ACC_READ_BIT) > #define EPT_VIOLATION_ACC_WRITE (1 << EPT_VIOLATION_ACC_WRITE_BIT) > @@ -553,6 +554,7 @@ enum vm_entry_failure_code { > #define EPT_VIOLATION_READABLE (1 << EPT_VIOLATION_READABLE_BIT) > #define EPT_VIOLATION_WRITABLE (1 << EPT_VIOLATION_WRITABLE_BIT) > #define EPT_VIOLATION_EXECUTABLE (1 << EPT_VIOLATION_EXECUTABLE_BIT) > +#define EPT_VIOLATION_GVA_VALIDATION (1 << EPT_VIOLATION_GVA_VALIDATION_BIT) > #define EPT_VIOLATION_GVA_TRANSLATED (1 << EPT_VIOLATION_GVA_TRANSLATED_BIT) > > /* > diff --git a/arch/x86/kvm/mmu/paging_tmpl.h b/arch/x86/kvm/mmu/paging_tmpl.h > index 95367f5ca998..7853c7ef13a1 100644 > --- a/arch/x86/kvm/mmu/paging_tmpl.h > +++ b/arch/x86/kvm/mmu/paging_tmpl.h > @@ -523,7 +523,8 @@ static int FNAME(walk_addr_generic)(struct guest_walker *walker, > * The other bits are set to 0. > */ > if (!(errcode & PFERR_RSVD_MASK)) { > - vcpu->arch.exit_qualification &= 0x180; > + vcpu->arch.exit_qualification &= (EPT_VIOLATION_GVA_VALIDATION > + | EPT_VIOLATION_GVA_TRANSLATED); Please put the | before the newline, and align the stuff inside the parantheses. That makes it must easier to see what the code is doing at a glance. vcpu->arch.exit_qualification &= (EPT_VIOLATION_GVA_IS_VALID | EPT_VIOLATION_GVA_TRANSLATED); > if (write_fault) > vcpu->arch.exit_qualification |= EPT_VIOLATION_ACC_WRITE; > if (user_fault) > -- > 2.32.0.3.g01195cf9f >