Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1953152pxp; Mon, 21 Mar 2022 08:19:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEQPkd5zHSnNkzXxebiwB0Mfoyw4VBN5hgtq7utHqKuAAvAyKMPVVCd5abc9Own2rDfjo8 X-Received: by 2002:a17:902:930b:b0:153:6924:d9e9 with SMTP id bc11-20020a170902930b00b001536924d9e9mr13497762plb.1.1647875958053; Mon, 21 Mar 2022 08:19:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647875958; cv=none; d=google.com; s=arc-20160816; b=BrJdiX0Hjqh9k1D2H/VZ4dY+M2XeQXAznbbfejby/XrTAKpkn/XzQOftTFUAyySaer hY8XUxL6MEZosxLcE54LSCQHdUckPBk87oOV0v5Sv5k+JdE5fsFiY86Cqi5YhW60wDKp 82IaEdQnKGh0g04NaPkHYW6zx9s9gBDaTh2ZahEDtFV3GcZDZ6dsxgjA1s3ebjMZeI7+ n09/OX0AO4CaME9Qh0n6iMXofT7jluIwBcx75nzjks3lMJGNhfUJki4kdgi5FUfeVKr6 uUXHzfMs9ZykzD1U57GAK22cutJsLo1m6QTqvk1koqE5p2hwnuWOyJ6aX/noyjAFLPpp EkuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=iHGQPzhLsak5TNRfteUSvjO5vDdK2rSABDJy1ETgu4A=; b=c+EYXS5OLUsYXKZzmCiG3YnB5k0x/NBdcfQXyQi26DCbbi3M3VnsGV63eJiueJhP+D /DHpquIOJ0TumrKYxMVaB4/KQKMRFpRffU4cKCHwMd2jwAV7NvdmpbIEFWyiEz7nPHbG 7E6HmQ9AIgyEdZAHMlLW/Esyyrc0310Oez5PYlMJLonTU99btJEk8kW7GVSd7OK4a8vx Q0UV1FQCZRUQBxMsmy/1xnqA9OIDXn7ePbMAWcLE+CO1XaD6v8gyZfWHc8YeBjvcAP31 0nNH3yiJoeoc67xg8Y8/efEUT/EUvQyQb21F18S2PLRdc7g0SKr4N97zZJ/JnPzXZ1Vl XmzQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=antgroup.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i6-20020a17090332c600b00153b2d165c3si14078180plr.459.2022.03.21.08.19.01; Mon, 21 Mar 2022 08:19:17 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=antgroup.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345984AbiCUJpG (ORCPT + 99 others); Mon, 21 Mar 2022 05:45:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345977AbiCUJpC (ORCPT ); Mon, 21 Mar 2022 05:45:02 -0400 Received: from out0-142.mail.aliyun.com (out0-142.mail.aliyun.com [140.205.0.142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3365C2BFC; Mon, 21 Mar 2022 02:43:35 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R761e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018047188;MF=darcy.sh@antgroup.com;NM=1;PH=DS;RN=16;SR=0;TI=SMTPD_---.N99gDLh_1647855811; Received: from localhost(mailfrom:darcy.sh@antgroup.com fp:SMTPD_---.N99gDLh_1647855811) by smtp.aliyun-inc.com(127.0.0.1); Mon, 21 Mar 2022 17:43:31 +0800 From: "SU Hang" To: kvm@vger.kernel.org Cc: "=?UTF-8?B?6LWW5rGf5bGx?=" , "SU Hang" , "Paolo Bonzini" , "Sean Christopherson" , "Vitaly Kuznetsov" , "Wanpeng Li" , "Jim Mattson" , "Joerg Roedel" , "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , "Dave Hansen" , , "H. Peter Anvin" , Subject: [PATCH 1/2] KVM: VMX: replace 0x180 with EPT_VIOLATION_* definition Date: Mon, 21 Mar 2022 17:42:02 +0800 Message-Id: <20220321094203.109546-1-darcy.sh@antgroup.com> X-Mailer: git-send-email 2.32.0.3.g01195cf9f MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY 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 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 #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); if (write_fault) vcpu->arch.exit_qualification |= EPT_VIOLATION_ACC_WRITE; if (user_fault) -- 2.32.0.3.g01195cf9f