From patchwork Sun Jun 5 06:34:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lai Jiangshan X-Patchwork-Id: 12869703 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E61FC43334 for ; Sun, 5 Jun 2022 06:33:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349656AbiFEGdf (ORCPT ); Sun, 5 Jun 2022 02:33:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349634AbiFEGdd (ORCPT ); Sun, 5 Jun 2022 02:33:33 -0400 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B443937BF6; Sat, 4 Jun 2022 23:33:31 -0700 (PDT) Received: by mail-pl1-x62d.google.com with SMTP id s12so9887536plp.0; Sat, 04 Jun 2022 23:33:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OlGYpcHVQA/YlW9Cm4xx1uTyQMaz0Myd/TiCIy2nB3o=; b=Zu/NphAdZBNIcPKZDnWHx5b7dDhCuefgQIOMBrqvWI+2e7pvQNAsguZF7ApPtV2+dW B1EmZX7/ZoyDKyG+G5nQEHSJGsScNOGHnzJ0gduKci63yRKSdEyYS5oE2m79fznuxXMp J5mn9qvVAgsVq9fG3uSxZPwIjnIk1tIjrVWiajKs6hf4oWT4jOdJ6dcsNqwB6tp2iPA+ GbSEdnuec6TBrK+k+EQfzdZiopbltqzld49NqzpTX0UwVz+qASp7YwgsHHKTlvdoH78Z 62uxaD6a1kPxy9Fi+t+S7tYurElMTU1mtowAscHtHsxr5S+Ws+dOVHekVYtreNTL6tSR aRIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OlGYpcHVQA/YlW9Cm4xx1uTyQMaz0Myd/TiCIy2nB3o=; b=sZsX41+YZ6V5Lz2B+4Pnf259BJETb4V1vSkiFhHUTtefZwyC0OygBuCkAuoEnUEzh2 J+Nqm9WDva9larg756ynm5lytspr/LQrq37abMdKrtST2MXLvtgiQ0uDmdPuTc1YShQp RBOryQnEWzOzFEW9U1/gFJZtqaBqwez28MvjkJupKpRzl1iijdX8NbCQXPwqiU7UBP8s INxAv+xKuIYgTTRSuSpOWksg7uMNvvYz+Meq72fopq3hHqdcTgUBt7csbISwZwcBiA0M LAA8bWug18e6X7ifI+qkiYZIms7/De3qjTRwVf/0Zxh3c+BvQYUFddXXFNQ0D/5p/AGl EvOw== X-Gm-Message-State: AOAM533f9+Gir59oflAYOA1clGRW9o11m63td8ZSVc+X6mmNh+zungAp IWA9qqNy0/dwrMwd7WUnp/9LYtbDayA= X-Google-Smtp-Source: ABdhPJyTzCmtKgk+nWl3bf17obTxv0KIw4TYKHX19NXXEAGpUtiJZh6bYiik18vWk5o/oTWOE8VsSg== X-Received: by 2002:a17:90a:c981:b0:1e6:75f0:d4ea with SMTP id w1-20020a17090ac98100b001e675f0d4eamr21018524pjt.37.1654410810897; Sat, 04 Jun 2022 23:33:30 -0700 (PDT) Received: from localhost ([198.11.178.15]) by smtp.gmail.com with ESMTPSA id u128-20020a626086000000b005184d1e838dsm8530423pfb.12.2022.06.04.23.33.30 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 04 Jun 2022 23:33:30 -0700 (PDT) From: Lai Jiangshan To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Maxim Levitsky , Lai Jiangshan Subject: [PATCH 1/6] KVM: X86/MMU: Remove unused macros from paging_tmpl.h Date: Sun, 5 Jun 2022 14:34:12 +0800 Message-Id: <20220605063417.308311-2-jiangshanlai@gmail.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20220605063417.308311-1-jiangshanlai@gmail.com> References: <20220605063417.308311-1-jiangshanlai@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Lai Jiangshan Remove unused PT_BASE_ADDR_MASK, PT_LEVEL_BITS, and CMPXCHG. Signed-off-by: Lai Jiangshan --- arch/x86/kvm/mmu/paging_tmpl.h | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/arch/x86/kvm/mmu/paging_tmpl.h b/arch/x86/kvm/mmu/paging_tmpl.h index db80f7ccaa4e..2375bd5fd9f4 100644 --- a/arch/x86/kvm/mmu/paging_tmpl.h +++ b/arch/x86/kvm/mmu/paging_tmpl.h @@ -24,17 +24,14 @@ #define pt_element_t u64 #define guest_walker guest_walker64 #define FNAME(name) paging##64_##name - #define PT_BASE_ADDR_MASK GUEST_PT64_BASE_ADDR_MASK #define PT_LVL_ADDR_MASK(lvl) PT64_LVL_ADDR_MASK(lvl) #define PT_LVL_OFFSET_MASK(lvl) PT64_LVL_OFFSET_MASK(lvl) #define PT_INDEX(addr, level) PT64_INDEX(addr, level) - #define PT_LEVEL_BITS PT64_LEVEL_BITS #define PT_GUEST_DIRTY_SHIFT PT_DIRTY_SHIFT #define PT_GUEST_ACCESSED_SHIFT PT_ACCESSED_SHIFT #define PT_HAVE_ACCESSED_DIRTY(mmu) true #ifdef CONFIG_X86_64 #define PT_MAX_FULL_LEVELS PT64_ROOT_MAX_LEVEL - #define CMPXCHG "cmpxchgq" #else #define PT_MAX_FULL_LEVELS 2 #endif @@ -42,30 +39,24 @@ #define pt_element_t u32 #define guest_walker guest_walker32 #define FNAME(name) paging##32_##name - #define PT_BASE_ADDR_MASK PT32_BASE_ADDR_MASK #define PT_LVL_ADDR_MASK(lvl) PT32_LVL_ADDR_MASK(lvl) #define PT_LVL_OFFSET_MASK(lvl) PT32_LVL_OFFSET_MASK(lvl) #define PT_INDEX(addr, level) PT32_INDEX(addr, level) - #define PT_LEVEL_BITS PT32_LEVEL_BITS #define PT_MAX_FULL_LEVELS 2 #define PT_GUEST_DIRTY_SHIFT PT_DIRTY_SHIFT #define PT_GUEST_ACCESSED_SHIFT PT_ACCESSED_SHIFT #define PT_HAVE_ACCESSED_DIRTY(mmu) true - #define CMPXCHG "cmpxchgl" #elif PTTYPE == PTTYPE_EPT #define pt_element_t u64 #define guest_walker guest_walkerEPT #define FNAME(name) ept_##name - #define PT_BASE_ADDR_MASK GUEST_PT64_BASE_ADDR_MASK #define PT_LVL_ADDR_MASK(lvl) PT64_LVL_ADDR_MASK(lvl) #define PT_LVL_OFFSET_MASK(lvl) PT64_LVL_OFFSET_MASK(lvl) #define PT_INDEX(addr, level) PT64_INDEX(addr, level) - #define PT_LEVEL_BITS PT64_LEVEL_BITS #define PT_GUEST_DIRTY_SHIFT 9 #define PT_GUEST_ACCESSED_SHIFT 8 #define PT_HAVE_ACCESSED_DIRTY(mmu) (!(mmu)->cpu_role.base.ad_disabled) #ifdef CONFIG_X86_64 - #define CMPXCHG "cmpxchgq" #endif #define PT_MAX_FULL_LEVELS PT64_ROOT_MAX_LEVEL #else @@ -1076,15 +1067,12 @@ static int FNAME(sync_page)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp) #undef pt_element_t #undef guest_walker #undef FNAME -#undef PT_BASE_ADDR_MASK #undef PT_INDEX #undef PT_LVL_ADDR_MASK #undef PT_LVL_OFFSET_MASK -#undef PT_LEVEL_BITS #undef PT_MAX_FULL_LEVELS #undef gpte_to_gfn #undef gpte_to_gfn_lvl -#undef CMPXCHG #undef PT_GUEST_ACCESSED_MASK #undef PT_GUEST_DIRTY_MASK #undef PT_GUEST_DIRTY_SHIFT From patchwork Sun Jun 5 06:34:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lai Jiangshan X-Patchwork-Id: 12869704 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA871CCA47F for ; Sun, 5 Jun 2022 06:33:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349634AbiFEGdi (ORCPT ); Sun, 5 Jun 2022 02:33:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349714AbiFEGdg (ORCPT ); Sun, 5 Jun 2022 02:33:36 -0400 Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4340F3879C; Sat, 4 Jun 2022 23:33:35 -0700 (PDT) Received: by mail-pg1-x532.google.com with SMTP id s68so10469794pgs.10; Sat, 04 Jun 2022 23:33:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=R820kjNKIxbkGEAKTjC7XUwmvnnoaBu0HN4Qfosm3J0=; b=pmsz3LNUmmxXTlSH9mZq67G4T5JalQR7Q1TcEhZ4W7pXtvGEZy4FQZMZ/qblh3ixTW 7CZcSllLwHNsW6FPTtTV9997ab6JGfsz2B4IC/EACpIoziaY6FDDiBt2GdiaJusgg5Nx bmfxEfap/5p6MN2FFZuN8wNqlePip3y734oU4PhxJc08ftB8GyUI5er5PnDPBXTmbgvn MziFrDWK+VH5vIjMdU3oOcII2pcrLWHanfQHu/qKVkOls68jsxiWtQucgREH6X6ziZBl honP47ocaRKZYEH1dcTSDneznUormOOsU9EdLPs+LQ3rElDreTp8wTvgmFQrhO1cVe5R pvaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=R820kjNKIxbkGEAKTjC7XUwmvnnoaBu0HN4Qfosm3J0=; b=OxsRnQV4f0/BKg87h2dVBDLCpA3gCRjnipePi6Rl9oSbWGOhrCxt7YeQSJLKMY8j35 URhkBbkqcRHg09HUheiC5ykvdGg4PTMKn04yATau7WMbrJHvrz6Ir/4HbYoV7pDxVu2b CSMNrHAc6a/Ckp7UZEMoJJEo/QhZD4UPg2sSIFkwz0pk3S3WpRq01SjpF+aqrj5lxnSP DR1Sq23+135bW/wZQS306RCGh5iSVOelIJ9fDioluXhd5gqH0sywE//M/iHQRMCE0vRo R19OQulcAN7Lyu/13WcPBNry2RCVNPPJZMINBLxSLwHtDuCYe03tiwmmywcScJkK/p9e 1rWA== X-Gm-Message-State: AOAM530ZvzoRi7ZnmmywZrwCF6bsywYhJyMpWZScbMXxjTpyr+Q1rv/v BaVT2kric2HrcMOU0G1uKZbaSdC7OKA= X-Google-Smtp-Source: ABdhPJznYNZ0pj5UHlTWjlFW8AWtjRydz077P6+f3/XnU070x08h25mql69PfY4IpMbns4iHrE9Fqg== X-Received: by 2002:a65:60d3:0:b0:39c:f431:5859 with SMTP id r19-20020a6560d3000000b0039cf4315859mr15641488pgv.442.1654410814670; Sat, 04 Jun 2022 23:33:34 -0700 (PDT) Received: from localhost ([198.11.178.15]) by smtp.gmail.com with ESMTPSA id i19-20020a17090320d300b00163f8ddf160sm8110451plb.161.2022.06.04.23.33.34 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 04 Jun 2022 23:33:34 -0700 (PDT) From: Lai Jiangshan To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Maxim Levitsky , Lai Jiangshan Subject: [PATCH 2/6] KVM: X86/MMU: Remove unused PT32_DIR_BASE_ADDR_MASK from mmu.c Date: Sun, 5 Jun 2022 14:34:13 +0800 Message-Id: <20220605063417.308311-3-jiangshanlai@gmail.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20220605063417.308311-1-jiangshanlai@gmail.com> References: <20220605063417.308311-1-jiangshanlai@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Lai Jiangshan It is unused. Signed-off-by: Lai Jiangshan --- arch/x86/kvm/mmu/mmu.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index efe5a3dca1e0..c935fdfc2544 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -125,8 +125,6 @@ module_param(dbg, bool, 0644); #define PT32_BASE_ADDR_MASK PAGE_MASK -#define PT32_DIR_BASE_ADDR_MASK \ - (PAGE_MASK & ~((1ULL << (PAGE_SHIFT + PT32_LEVEL_BITS)) - 1)) #define PT32_LVL_ADDR_MASK(level) \ (PAGE_MASK & ~((1ULL << (PAGE_SHIFT + (((level) - 1) \ * PT32_LEVEL_BITS))) - 1)) From patchwork Sun Jun 5 06:34:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lai Jiangshan X-Patchwork-Id: 12869705 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14A6EC43334 for ; Sun, 5 Jun 2022 06:33:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349714AbiFEGdq (ORCPT ); Sun, 5 Jun 2022 02:33:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349846AbiFEGdk (ORCPT ); Sun, 5 Jun 2022 02:33:40 -0400 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 1167138D84; Sat, 4 Jun 2022 23:33:39 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id a10so10426356pju.3; Sat, 04 Jun 2022 23:33:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=k6u1NoOEvXwJSKIzoGXM9388wPway6Xp+Y1moK1bhxQ=; b=Oe+NHUjWzyjI5Ssvs1op6RF7SojwDqU4VJxgWcBfZUvjr8L7poTUt0Qr4pIZqnmSgu N+WsOyRqHtZCZ5P9lsVZTFqv0aaKN/AUF1XcDC2L8UjcT4FI0sdvR6jzKwX8p3WtANfe /opiSKml8t9+WXzUOjtJAgaz3F8zTTSGrw6XuOWPvtMcXHlfYMR5mjTpIePBKpiq8JeF qvZU6nr/oFkW05XJk+DLiy6NKXM/xMAQLVz0avP1X0pKVnymz+1KUT6JU1pKcr8RERBz ei5lR3W/lNo17IVJe++GBAV0SzUzki0eGeOWqtsFyhJBGMlJIvL0JWytz0QbUQwq2RyT v1/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=k6u1NoOEvXwJSKIzoGXM9388wPway6Xp+Y1moK1bhxQ=; b=EnmkF+wJZy1hqxtP7CTJGCQP+jPoBjkS/rhDqE52J/Hy8zJSEnuVwBrnyyCugNPKeb p2EFV6xhO1ULpoGRPBXvIH8SD+EbX5vEyCJ4PLzlaRLiorKC3UvimyLXNTGOhSdAllKn TefaQiM4TYMMKHKYHavWMrNIF5tc9oTD2CcxHbGwUEF/VBMJFaQu8n8smWRZZrBqdcR1 N3KyjJKljR5DdLxpSD4YSnvDlUkb6F80Kk2RirJBmMqsxCrHvzAD/JCuxAjlLawdkMIn bugcei9R1ocYzwEkzNfaXkyFxlJndDXCh8ROhzYF2nuSkY16GArSuNg0Ae/PlOzkSCRU UcLg== X-Gm-Message-State: AOAM5320yrFose9tcUE69jpvTmMEW0EBBgvCHmU95um7aEB7+jcomKp4 ZyKO0KowerDHk2Xj7fTxK/KUxpq+3ME= X-Google-Smtp-Source: ABdhPJxy3PmT3XLu7ZvLfuPrbxGySAApXeGxPHIiOxjjF1aKIq+zxDeB6RxzSTbfBgsxWzasEVTTmw== X-Received: by 2002:a17:90b:4a12:b0:1e3:15ef:81e1 with SMTP id kk18-20020a17090b4a1200b001e315ef81e1mr34274027pjb.246.1654410818489; Sat, 04 Jun 2022 23:33:38 -0700 (PDT) Received: from localhost ([198.11.178.15]) by smtp.gmail.com with ESMTPSA id 3-20020a630803000000b003c2f9540127sm7996265pgi.93.2022.06.04.23.33.37 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 04 Jun 2022 23:33:38 -0700 (PDT) From: Lai Jiangshan To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Maxim Levitsky , Lai Jiangshan Subject: [PATCH 3/6] KVM: X86/MMU: Update comments in paging_tmpl.h for the kinds of guest PTEs Date: Sun, 5 Jun 2022 14:34:14 +0800 Message-Id: <20220605063417.308311-4-jiangshanlai@gmail.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20220605063417.308311-1-jiangshanlai@gmail.com> References: <20220605063417.308311-1-jiangshanlai@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Lai Jiangshan Add EPT PTEs into the comments. Signed-off-by: Lai Jiangshan --- arch/x86/kvm/mmu/paging_tmpl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/mmu/paging_tmpl.h b/arch/x86/kvm/mmu/paging_tmpl.h index 2375bd5fd9f4..f4e02ba04744 100644 --- a/arch/x86/kvm/mmu/paging_tmpl.h +++ b/arch/x86/kvm/mmu/paging_tmpl.h @@ -16,8 +16,8 @@ */ /* - * We need the mmu code to access both 32-bit and 64-bit guest ptes, - * so the code in this file is compiled twice, once per pte size. + * We need the MMU code to access 32-bit, 64-bit PTEs and 64-bit EPT PTEs, + * so the code in this file is compiled three times, once per a kind of PTE. */ #if PTTYPE == 64 From patchwork Sun Jun 5 06:34:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lai Jiangshan X-Patchwork-Id: 12869706 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA155C43334 for ; Sun, 5 Jun 2022 06:33:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350033AbiFEGdr (ORCPT ); Sun, 5 Jun 2022 02:33:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349900AbiFEGdp (ORCPT ); Sun, 5 Jun 2022 02:33:45 -0400 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7F7938DAA; Sat, 4 Jun 2022 23:33:43 -0700 (PDT) Received: by mail-pg1-x52b.google.com with SMTP id r71so10516667pgr.0; Sat, 04 Jun 2022 23:33:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UIh9uECf7BlKLTjyvtoYPpgqACtGyu4JH9Y3de5XW28=; b=ir2lWXdIQD45DVM1rRbVnulolV3JKpfOvofww+NQvf1uScmMZC3enik0NMazaVRtpg td/HMuaY/BRnO6+AXURoYJCyqKRAzMDgtrvSB5+MPqo7Qy5gWRClvtNYF0c6JT4pna62 G47j3FIK6ZJY86WXtV6ZPF3H8Fh+s1ACMUzsU9dENPSMys0tiC0pN0gnxol9F0eVnDjP QL8pa7KLlVDZoHTXl//HAHhixJNVhKnlbsI96L+ABiVQVgMzOPao3FIXIdHPsYZ1jo3I SRTWb+V4Q7Qz+Gqdl3Aq10s0h44BVOLqGvyQNsia49hqQAYYBtZWE2+e2dkoEMkC6JWn ulUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UIh9uECf7BlKLTjyvtoYPpgqACtGyu4JH9Y3de5XW28=; b=vISY+hSk37Y+Doxp96Mq9iC0baYviHGNEOuQEu3LyIgz3wrJXAKLMIp+tlYLjrHu8q /FOYe47s1CgvFB8l14Kkee8hkGeKHzBHQXv81hoDlKNiM209sv6ObxyUTlK4ZCHWZXFG ShS35Xxt+vd5CAMvpqTXVA9yaZ573k9fd+RR3WX9Ih/7YL+k5ByVE7lr9QpdsmupkR86 FbxD2vaUp6w4Fv1S3iIi2dLJC3c0n9yRbVPtQef8fJU/vO9jyk3uERb0wCPR1PBe+YLI LFnliNszgq+mDSwi77Vf5OdBG0oCi07TnLDFxoy9ZuxSGBnfgip/3jVWwWla/aagpNrT KigQ== X-Gm-Message-State: AOAM533fM9/DiRfsj9NtwO/TXm3eZbE8ZAkxEFZRXLTS0X7yA8jFufj9 OH1SqSc/zHwxW4vaMNPVROMl1wsI8Hc= X-Google-Smtp-Source: ABdhPJzmXVU3G5U9LXZb8gIuFkBNh5lZxpPavH1Px2YvEZrIBM8jdWoDaVMDeNowjmKay9nSHwiPiQ== X-Received: by 2002:a65:6786:0:b0:3fc:e1c0:7bbc with SMTP id e6-20020a656786000000b003fce1c07bbcmr14211150pgr.65.1654410822390; Sat, 04 Jun 2022 23:33:42 -0700 (PDT) Received: from localhost ([198.11.178.15]) by smtp.gmail.com with ESMTPSA id h2-20020a635742000000b003db580384d6sm8092270pgm.60.2022.06.04.23.33.41 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 04 Jun 2022 23:33:42 -0700 (PDT) From: Lai Jiangshan To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Maxim Levitsky , Lai Jiangshan Subject: [PATCH 4/6] KVM: Rename ack_flush() to ack_kick() Date: Sun, 5 Jun 2022 14:34:15 +0800 Message-Id: <20220605063417.308311-5-jiangshanlai@gmail.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20220605063417.308311-1-jiangshanlai@gmail.com> References: <20220605063417.308311-1-jiangshanlai@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Lai Jiangshan Make it use the same verb as in kvm_kick_many_cpus(). Signed-off-by: Lai Jiangshan --- virt/kvm/kvm_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index e089db822c12..00c899393418 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -235,7 +235,7 @@ static bool kvm_request_needs_ipi(struct kvm_vcpu *vcpu, unsigned req) return mode == IN_GUEST_MODE; } -static void ack_flush(void *_completed) +static void ack_kick(void *_completed) { } @@ -244,7 +244,7 @@ static inline bool kvm_kick_many_cpus(struct cpumask *cpus, bool wait) if (cpumask_empty(cpus)) return false; - smp_call_function_many(cpus, ack_flush, NULL, wait); + smp_call_function_many(cpus, ack_kick, NULL, wait); return true; } From patchwork Sun Jun 5 06:34:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lai Jiangshan X-Patchwork-Id: 12869707 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50A9AC43334 for ; Sun, 5 Jun 2022 06:33:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350369AbiFEGdt (ORCPT ); Sun, 5 Jun 2022 02:33:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349893AbiFEGdr (ORCPT ); Sun, 5 Jun 2022 02:33:47 -0400 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D844839833; Sat, 4 Jun 2022 23:33:46 -0700 (PDT) Received: by mail-pf1-x431.google.com with SMTP id w21so10391147pfc.0; Sat, 04 Jun 2022 23:33:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YvwhpBEVr+JVMGhFVSm13HlZhDft0aOf75cXo07eXkQ=; b=IMk0sQHgGvvPa0UgEbBM96DpYC+oyg/kzYecPLGUEo8WIL1tUsf5G+nwCX9er8HKgK SPlnECrH3eTy0DGrFeh72HblzEyDQrcIrLxwgrBcZ6b0gvmf2iLknuCwpaFJvkzsV3vk v813oLBXjJLkzqttbuav6y0I2lV8gpbGPtMw9FbJxGd/rNT1qaqk9OL4Yqd9h0AKkf6k 97wW4YyPHjbOgdPzXE5XU2L5s7tT7x65bPaDPMI+EPg1VGLeIGwA1D1+VN36G5ZAizeY mpSalOSPAhFyfBRpyCpdBv8eDgWaGR7PTVuc7LX/yF5ivN4eXf9D5oIlnKmu5l7Phn4e y6nQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YvwhpBEVr+JVMGhFVSm13HlZhDft0aOf75cXo07eXkQ=; b=vuew2c+zqVKoPXBMhchWGieEc/dI839AWdp5wF5RVtReCsBB4OmoCuvylhVzootOe6 B9b1/6L6MLHnqA1/wcbcZwEyrdSt8wjl9Bzmwq1uxLIL32U3DiuWjEfYPDC8aWIo9bNp fHVOIAyW+RLjLblG33iqioFW5pz6QhhneMVMAz95LHPVlGByhQOCrlBG/zuHQxUQ6UFc jH/qa3kKcUmJRrBZRmNT56w5NQb1cFgN6qvVK0UUvKMPoEO8ZmZIAomySTEA5eqGLk+G Cs9u27bq7wzjWBEyc311Ck2hOTksWosT0DqoSVCPirKW52GPTpvQxAltiStzOfGK19uf JSnw== X-Gm-Message-State: AOAM532b45bpRa3W2tB3WKC5JQwGqpDsVVZp8KfEfS7Nyeo14pV1xxAp LXJ8QzpZz46mPfvXV0Kik7xyXRzmpjY= X-Google-Smtp-Source: ABdhPJwQ3dNEnHqhPyUif8oNJ68gFVPJJltPU4Yfi0T6n3Bckn7nSLu5ZZ1D4XT01FiiYx0+Yi0GMQ== X-Received: by 2002:a63:131a:0:b0:3fa:aa7e:b28a with SMTP id i26-20020a63131a000000b003faaa7eb28amr15537460pgl.569.1654410826217; Sat, 04 Jun 2022 23:33:46 -0700 (PDT) Received: from localhost ([198.11.178.15]) by smtp.gmail.com with ESMTPSA id w25-20020aa78599000000b0051bc22c153asm6599970pfn.65.2022.06.04.23.33.45 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 04 Jun 2022 23:33:46 -0700 (PDT) From: Lai Jiangshan To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Maxim Levitsky , Lai Jiangshan Subject: [PATCH 5/6] KVM: X86/MMU: Remove useless mmu_topup_memory_caches() in kvm_mmu_pte_write() Date: Sun, 5 Jun 2022 14:34:16 +0800 Message-Id: <20220605063417.308311-6-jiangshanlai@gmail.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20220605063417.308311-1-jiangshanlai@gmail.com> References: <20220605063417.308311-1-jiangshanlai@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Lai Jiangshan Since the commit c5e2184d1544("KVM: x86/mmu: Remove the defunct update_pte() paging hook"), kvm_mmu_pte_write() no longer uses the rmap cache. So remove mmu_topup_memory_caches() in it. Cc: Sean Christopherson Signed-off-by: Lai Jiangshan --- arch/x86/kvm/mmu/mmu.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index c935fdfc2544..086f32dffdbe 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -5326,13 +5326,6 @@ static void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa, pgprintk("%s: gpa %llx bytes %d\n", __func__, gpa, bytes); - /* - * No need to care whether allocation memory is successful - * or not since pte prefetch is skipped if it does not have - * enough objects in the cache. - */ - mmu_topup_memory_caches(vcpu, true); - write_lock(&vcpu->kvm->mmu_lock); gentry = mmu_pte_write_fetch_gpte(vcpu, &gpa, &bytes); From patchwork Sun Jun 5 06:34:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lai Jiangshan X-Patchwork-Id: 12869708 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92C38C433EF for ; Sun, 5 Jun 2022 06:34:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350705AbiFEGeC (ORCPT ); Sun, 5 Jun 2022 02:34:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350702AbiFEGd5 (ORCPT ); Sun, 5 Jun 2022 02:33:57 -0400 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B42F139BA6; Sat, 4 Jun 2022 23:33:50 -0700 (PDT) Received: by mail-pj1-x102e.google.com with SMTP id v5-20020a17090a7c0500b001df84fa82f8so10176705pjf.5; Sat, 04 Jun 2022 23:33:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NUqtccdmHpVOa+ywhrLDU/DEc/VQZ0bOnsbWDSLDOhE=; b=SWegMuBHwVm86rAMIdjeOqJQmSxdml17S0fO9qMiE26K9ALz8kNPDUz0JAT0JdA9tM lf9Vr9q0qeNGIvOh5U7I1HFsr7A6F7V5QCzMWzzwaf6uYuCpGEtWD4l7jbRAjEuXBLM4 WiPTxOkWkoI/bf66whbmr0lDQqE7pP3qw9czwuMWWr/blhoSvT57KsQDK7vQISNFvz1z AIfjiOQaOFVqo2CaNjbeID5tyr5L4qENYEw1lKrc3gAQ08+RTsCkFFaXHeEKSzutJMri Ji5rPZKyWj377D/1UBimDpIZ85LYAm3TK+Y6nWqYTGPWcpSItSzi2Wwn/N7EMN8VjW4k s+uA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NUqtccdmHpVOa+ywhrLDU/DEc/VQZ0bOnsbWDSLDOhE=; b=56wEgLngi7aFEWqBeWHqWmq6vY+0c/ey/nv51+GM/Igyw3E2U9bNra1BOZLXySJDwD gU6fJ0IhT9ZNWUchP9uM1aKFOiyfjkO/5rtC7mm+3McQUXIkZ3t/z3tSLcW1jUHaVQlN i/gbunboUiB41NwOamrYHgc1/MHUDjZEhNEXbOKMv5ODEAARFCdkXkIWU5DDw0MbR52k dvxpxXkR7+OYXmhgMfw57WPr/aSSdwlVVF3q9wyA4yJ/AJ/ODUqZwqA7rhrM5G0UuX5A aAKL9VusJrJBkxfHOu4diUo4W7fOqvzP6PB2R1sPgmK1eA0T8X9UkbsfgNmR9aUkGynF pjCg== X-Gm-Message-State: AOAM531jVvtuYwv1gimYaYu1dM2QK6DbLFR3H8BsW1BE2erQ8OpTrvHw 874OMq7wkm7/VQvPwE8zBcV+Z1ihcP0= X-Google-Smtp-Source: ABdhPJxg9O5VcnLtJYttD3zdKhVKxVGRXqauAI0C8YF/4D5lxoH63YNeChP+lE2eADEHBk/mJ4qAYw== X-Received: by 2002:a17:902:f605:b0:14d:bd53:e2cd with SMTP id n5-20020a170902f60500b0014dbd53e2cdmr17930942plg.164.1654410830007; Sat, 04 Jun 2022 23:33:50 -0700 (PDT) Received: from localhost ([198.11.178.15]) by smtp.gmail.com with ESMTPSA id s21-20020a635255000000b003db072fd9adsm8113867pgl.74.2022.06.04.23.33.49 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 04 Jun 2022 23:33:49 -0700 (PDT) From: Lai Jiangshan To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Maxim Levitsky , Lai Jiangshan Subject: [PATCH 6/6] KVM: X86/SVM: Use root_level in svm_load_mmu_pgd() Date: Sun, 5 Jun 2022 14:34:17 +0800 Message-Id: <20220605063417.308311-7-jiangshanlai@gmail.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20220605063417.308311-1-jiangshanlai@gmail.com> References: <20220605063417.308311-1-jiangshanlai@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Lai Jiangshan The caller always call it with root_level = vcpu->arch.mmu->root_role.level. Signed-off-by: Lai Jiangshan --- arch/x86/kvm/svm/svm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 3b49337998ec..f45d11739314 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -3951,7 +3951,7 @@ static void svm_load_mmu_pgd(struct kvm_vcpu *vcpu, hpa_t root_hpa, hv_track_root_tdp(vcpu, root_hpa); cr3 = vcpu->arch.cr3; - } else if (vcpu->arch.mmu->root_role.level >= PT64_ROOT_4LEVEL) { + } else if (root_level >= PT64_ROOT_4LEVEL) { cr3 = __sme_set(root_hpa) | kvm_get_active_pcid(vcpu); } else { /* PCID in the guest should be impossible with a 32-bit MMU. */