From patchwork Wed Jan 11 00:02:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 13095782 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 44E62C54EBC for ; Wed, 11 Jan 2023 00:14:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=NPy2PcWMwhuOHuS0TfxY5anOtqqxzgcaWyUkjk2B8OY=; b=bx5h3a62aeVWJn 3kj8Qd1CICfVT/1ThPBVZoCsi3BAXFb+f6YJB5C3qn+MpOuwrgXq/PCL1o7+Co40pox9ZjeJmhhUf 2BvI0p2+ltTx+G70u4krNRGeiCuewPUnzZoyPrVTu/E+Wx51xVJjyzmJqOms+1jp2py26+DnF49Uw XgnCfUrTr4ZXXuoZLVrTE9HcDogG04pBgs3O5dkakx7HaTsINHDykHzU94JiX/iDB/SnsfNeHKyIl 3kUvMysodI94c/LJWGfX6snphwhUx7QzuErugHJYprUQ6yPTChLSpy6vtBk92VfmShx8/4vjRnQyy KYh9oe/8ZwAeUxLeAa1Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFOk6-0090bI-NU; Wed, 11 Jan 2023 00:13:22 +0000 Received: from out-119.mta0.migadu.com ([2001:41d0:1004:224b::77]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFOk3-0090aU-4a for linux-arm-kernel@lists.infradead.org; Wed, 11 Jan 2023 00:13:20 +0000 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1673395414; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=D5xfAEmK6VbYRFlnNHDhaBUhTqgSFqiHTqH3/+fHTPQ=; b=WFlbHAWIc0zs7pU3bGakD+YbD6DjlilnvKS7Z4K2n3quKoQYoqjGuad2ewHQYlZFFZpgdf 9Wby05Yg8EbUWk8zD1Q3ZeKGIHJCSZS1EBwVcq1sdj87s/3GdSLb5O4Wf8vk71NrBLzxrq D0iPGWjEOekptCy+xy6kIm9zvAuQNoE= From: Oliver Upton To: Marc Zyngier , James Morse Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, Quentin Perret , Will Deacon , Reiji Watanabe , Oliver Upton Subject: [PATCH 1/5] KVM: arm64: Hoist S2 PTE definitions into kvm_pgtable.h Date: Wed, 11 Jan 2023 00:02:56 +0000 Message-Id: <20230111000300.2034799-2-oliver.upton@linux.dev> In-Reply-To: <20230111000300.2034799-1-oliver.upton@linux.dev> References: <20230111000300.2034799-1-oliver.upton@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230110_161319_324368_30638A65 X-CRM114-Status: UNSURE ( 8.76 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org KVM's definitions for S2 PTEs are scattered between kvm_pgtable.h and pgtable.c. Keep it all in one place by moving it all into the header. No functional change intended. Signed-off-by: Oliver Upton --- arch/arm64/include/asm/kvm_pgtable.h | 34 ++++++++++++++++++++++++++++ arch/arm64/kvm/hyp/pgtable.c | 34 ---------------------------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/arch/arm64/include/asm/kvm_pgtable.h b/arch/arm64/include/asm/kvm_pgtable.h index 63f81b27a4e3..8071698cc680 100644 --- a/arch/arm64/include/asm/kvm_pgtable.h +++ b/arch/arm64/include/asm/kvm_pgtable.h @@ -39,6 +39,40 @@ typedef u64 kvm_pte_t; #define KVM_PTE_VALID BIT(0) +#define KVM_PTE_TYPE BIT(1) +#define KVM_PTE_TYPE_BLOCK 0 +#define KVM_PTE_TYPE_PAGE 1 +#define KVM_PTE_TYPE_TABLE 1 + +#define KVM_PTE_LEAF_ATTR_LO GENMASK(11, 2) + +#define KVM_PTE_LEAF_ATTR_LO_S1_ATTRIDX GENMASK(4, 2) +#define KVM_PTE_LEAF_ATTR_LO_S1_AP GENMASK(7, 6) +#define KVM_PTE_LEAF_ATTR_LO_S1_AP_RO 3 +#define KVM_PTE_LEAF_ATTR_LO_S1_AP_RW 1 +#define KVM_PTE_LEAF_ATTR_LO_S1_SH GENMASK(9, 8) +#define KVM_PTE_LEAF_ATTR_LO_S1_SH_IS 3 +#define KVM_PTE_LEAF_ATTR_LO_S1_AF BIT(10) + +#define KVM_PTE_LEAF_ATTR_LO_S2_MEMATTR GENMASK(5, 2) +#define KVM_PTE_LEAF_ATTR_LO_S2_S2AP_R BIT(6) +#define KVM_PTE_LEAF_ATTR_LO_S2_S2AP_W BIT(7) +#define KVM_PTE_LEAF_ATTR_LO_S2_SH GENMASK(9, 8) +#define KVM_PTE_LEAF_ATTR_LO_S2_SH_IS 3 +#define KVM_PTE_LEAF_ATTR_LO_S2_AF BIT(10) + +#define KVM_PTE_LEAF_ATTR_HI GENMASK(63, 51) + +#define KVM_PTE_LEAF_ATTR_HI_SW GENMASK(58, 55) + +#define KVM_PTE_LEAF_ATTR_HI_S1_XN BIT(54) + +#define KVM_PTE_LEAF_ATTR_HI_S2_XN BIT(54) + +#define KVM_PTE_LEAF_ATTR_S2_PERMS (KVM_PTE_LEAF_ATTR_LO_S2_S2AP_R | \ + KVM_PTE_LEAF_ATTR_LO_S2_S2AP_W | \ + KVM_PTE_LEAF_ATTR_HI_S2_XN) + #define KVM_PTE_ADDR_MASK GENMASK(47, PAGE_SHIFT) #define KVM_PTE_ADDR_51_48 GENMASK(15, 12) diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c index b11cf2c618a6..3efe3aca3cb9 100644 --- a/arch/arm64/kvm/hyp/pgtable.c +++ b/arch/arm64/kvm/hyp/pgtable.c @@ -12,40 +12,6 @@ #include -#define KVM_PTE_TYPE BIT(1) -#define KVM_PTE_TYPE_BLOCK 0 -#define KVM_PTE_TYPE_PAGE 1 -#define KVM_PTE_TYPE_TABLE 1 - -#define KVM_PTE_LEAF_ATTR_LO GENMASK(11, 2) - -#define KVM_PTE_LEAF_ATTR_LO_S1_ATTRIDX GENMASK(4, 2) -#define KVM_PTE_LEAF_ATTR_LO_S1_AP GENMASK(7, 6) -#define KVM_PTE_LEAF_ATTR_LO_S1_AP_RO 3 -#define KVM_PTE_LEAF_ATTR_LO_S1_AP_RW 1 -#define KVM_PTE_LEAF_ATTR_LO_S1_SH GENMASK(9, 8) -#define KVM_PTE_LEAF_ATTR_LO_S1_SH_IS 3 -#define KVM_PTE_LEAF_ATTR_LO_S1_AF BIT(10) - -#define KVM_PTE_LEAF_ATTR_LO_S2_MEMATTR GENMASK(5, 2) -#define KVM_PTE_LEAF_ATTR_LO_S2_S2AP_R BIT(6) -#define KVM_PTE_LEAF_ATTR_LO_S2_S2AP_W BIT(7) -#define KVM_PTE_LEAF_ATTR_LO_S2_SH GENMASK(9, 8) -#define KVM_PTE_LEAF_ATTR_LO_S2_SH_IS 3 -#define KVM_PTE_LEAF_ATTR_LO_S2_AF BIT(10) - -#define KVM_PTE_LEAF_ATTR_HI GENMASK(63, 51) - -#define KVM_PTE_LEAF_ATTR_HI_SW GENMASK(58, 55) - -#define KVM_PTE_LEAF_ATTR_HI_S1_XN BIT(54) - -#define KVM_PTE_LEAF_ATTR_HI_S2_XN BIT(54) - -#define KVM_PTE_LEAF_ATTR_S2_PERMS (KVM_PTE_LEAF_ATTR_LO_S2_S2AP_R | \ - KVM_PTE_LEAF_ATTR_LO_S2_S2AP_W | \ - KVM_PTE_LEAF_ATTR_HI_S2_XN) - #define KVM_INVALID_PTE_OWNER_MASK GENMASK(9, 2) #define KVM_MAX_OWNER_ID 1 From patchwork Wed Jan 11 00:02:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 13095777 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B702DC46467 for ; Wed, 11 Jan 2023 00:04:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Zlq1M9V+RRWcNqzaIPdc0GXTrOg6faQAQegmeFK8ip8=; b=plya9h+GlFDs/d c+s/Zvv3jeXfO+yM+xDmuarnnT7wrVDJ+tJMEn0+TSgOooMkGiBvMDHAbMo4HLvjK5ikOPzJwVVWK n18cKGg8zjNyFjI2wlTAmOhp5JgUaN8ETyh1gc7YRKa0Y9AhOwY3tJ4XI7jxraijfJpB3nYvlSu67 x9fghzQScYVGOC7AuMfi9e80Wvqde6qT2erBBjs84JT4mKJxQrQuCstAyNJ1hoVIowG3QOq6Xlb5D DaBSUKdKq2vZJEXfjpAZDZB+alUydbjFRwFR2OBVJsCQVSzQVgl4IuTU0C2FSLyGpB/TgRpDmWsM0 PDTFo/4TQWl42GHAJZCg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFOaq-008yAu-VR; Wed, 11 Jan 2023 00:03:49 +0000 Received: from out-246.mta0.migadu.com ([91.218.175.246]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFOag-008y7T-VI for linux-arm-kernel@lists.infradead.org; Wed, 11 Jan 2023 00:03:40 +0000 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1673395415; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dAXX/LNlPU0/7x/WB4sHfAEpk6aprKisr31vwb0y/J8=; b=rVdEIqr8nA4DZ0XZnB6dpg6NqL8ss9zcS6ljQu0ScAqDn7Ex0/tR+GZUXTBrnHfQDj3JkE ZftP2b2B3vJtXev9rt83En5kutZG7+iIa7S9lyOAGHvua4rNBcnxXq1THmnR63aVDn2wnE Cx5chH2cJisrpGtaLO37mctfcSrepu4= From: Oliver Upton To: Marc Zyngier , James Morse Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, Quentin Perret , Will Deacon , Reiji Watanabe , Oliver Upton Subject: [PATCH 2/5] KVM: arm64: Add a mask for all leaf PTE attributes Date: Wed, 11 Jan 2023 00:02:57 +0000 Message-Id: <20230111000300.2034799-3-oliver.upton@linux.dev> In-Reply-To: <20230111000300.2034799-1-oliver.upton@linux.dev> References: <20230111000300.2034799-1-oliver.upton@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230110_160339_172102_8B47CCA2 X-CRM114-Status: UNSURE ( 9.65 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org No functional change intended. Signed-off-by: Oliver Upton --- arch/arm64/include/asm/kvm_pgtable.h | 3 +++ arch/arm64/kvm/hyp/pgtable.c | 7 +++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/arm64/include/asm/kvm_pgtable.h b/arch/arm64/include/asm/kvm_pgtable.h index 8071698cc680..f8f6b4d2735a 100644 --- a/arch/arm64/include/asm/kvm_pgtable.h +++ b/arch/arm64/include/asm/kvm_pgtable.h @@ -73,6 +73,9 @@ typedef u64 kvm_pte_t; KVM_PTE_LEAF_ATTR_LO_S2_S2AP_W | \ KVM_PTE_LEAF_ATTR_HI_S2_XN) +#define KVM_PTE_LEAF_ATTRS (KVM_PTE_LEAF_ATTR_LO | \ + KVM_PTE_LEAF_ATTR_HI) + #define KVM_PTE_ADDR_MASK GENMASK(47, PAGE_SHIFT) #define KVM_PTE_ADDR_51_48 GENMASK(15, 12) diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c index 3efe3aca3cb9..26f61462527d 100644 --- a/arch/arm64/kvm/hyp/pgtable.c +++ b/arch/arm64/kvm/hyp/pgtable.c @@ -111,7 +111,7 @@ static kvm_pte_t kvm_init_valid_leaf_pte(u64 pa, kvm_pte_t attr, u32 level) u64 type = (level == KVM_PGTABLE_MAX_LEVELS - 1) ? KVM_PTE_TYPE_PAGE : KVM_PTE_TYPE_BLOCK; - pte |= attr & (KVM_PTE_LEAF_ATTR_LO | KVM_PTE_LEAF_ATTR_HI); + pte |= attr & KVM_PTE_LEAF_ATTRS; pte |= FIELD_PREP(KVM_PTE_TYPE, type); pte |= KVM_PTE_VALID; @@ -1027,10 +1027,9 @@ static int stage2_update_leaf_attrs(struct kvm_pgtable *pgt, u64 addr, u32 *level, enum kvm_pgtable_walk_flags flags) { int ret; - kvm_pte_t attr_mask = KVM_PTE_LEAF_ATTR_LO | KVM_PTE_LEAF_ATTR_HI; struct stage2_attr_data data = { - .attr_set = attr_set & attr_mask, - .attr_clr = attr_clr & attr_mask, + .attr_set = attr_set & KVM_PTE_LEAF_ATTRS, + .attr_clr = attr_clr & KVM_PTE_LEAF_ATTRS, }; struct kvm_pgtable_walker walker = { .cb = stage2_attr_walker, From patchwork Wed Jan 11 00:02:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 13095778 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 24005C54EBC for ; Wed, 11 Jan 2023 00:04:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3nvJl4c9A5evk2ZZyIe68MyYvNcE2cnjNVo7PMXqeWk=; b=R0FtvwGJW0JEp2 P1tc8EbFnsiT1M6Jx3ZOwaSt/x0Co2p9aLqqKMHcHCerwgWkxgVpvtgFgOalRWY4dWpUTKCsJBWvn V1+ntk/2UA1slxGCNMxg9Ai3S+fEiutBjESvnJ3le8N61gm7nMzq5aFPALM4kTphu+QnkrpzUtGoG cACEHtQCY2srBjpZS0+EUpzEHRToXeZ4fpTLVTOVmnS6oJYnyS0VFJH/VPb5IsMTclq86GESVBXco qPmqYj5Nhn/wbvLMbZ0jFYVOjY6UL/QL0S2jecbUtIz9TlX+b0ahmfM88V8PmE5U5sXsnsyMWy5IS a9tkhscdLR73kkCW+qrA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFOaz-008yCU-0m; Wed, 11 Jan 2023 00:03:57 +0000 Received: from out-19.mta0.migadu.com ([2001:41d0:1004:224b::13]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFOaj-008y7w-05 for linux-arm-kernel@lists.infradead.org; Wed, 11 Jan 2023 00:03:42 +0000 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1673395417; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9DaZ0SEJg/u0gD0sqTLBat7vEekCCjd/sgW7siDQbQc=; b=g/DwgKH8bvg45KPU6YRLGlNUG4UZsdxoNT/dwf28ZG+d3UWG/DlpfhRgo0ONAzBRCdX03F s7ACXEEgRPFxncHXpaNmzVrVTyrzlqLFaasd0vJ9MGAxAYKDNrkLQbq+dM0DOrJgKgwZ4S 1FoFzTi5+7HIsqHTX6RHJTV2DIQKmls= From: Oliver Upton To: Marc Zyngier , James Morse Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, Quentin Perret , Will Deacon , Reiji Watanabe , Oliver Upton Subject: [PATCH 3/5] KVM: arm64: Only return attributes from stage2_update_leaf_attrs() Date: Wed, 11 Jan 2023 00:02:58 +0000 Message-Id: <20230111000300.2034799-4-oliver.upton@linux.dev> In-Reply-To: <20230111000300.2034799-1-oliver.upton@linux.dev> References: <20230111000300.2034799-1-oliver.upton@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230110_160341_231024_6DD0FF67 X-CRM114-Status: GOOD ( 15.75 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Returning a single PTE from stage2_update_leaf_attrs() doesn't make a great deal of sense given that the function could be used to apply a change to a range of PTEs. Instead, return a bitwise OR of attributes from all the visited PTEs. As the walker is no longer returning the full PTE, drop the check for a valid PTE in kvm_age_gfn(). Signed-off-by: Oliver Upton --- arch/arm64/kvm/hyp/pgtable.c | 32 +++++++++++++++++--------------- arch/arm64/kvm/mmu.c | 2 +- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c index 26f61462527d..a3d599e3af60 100644 --- a/arch/arm64/kvm/hyp/pgtable.c +++ b/arch/arm64/kvm/hyp/pgtable.c @@ -980,7 +980,7 @@ int kvm_pgtable_stage2_unmap(struct kvm_pgtable *pgt, u64 addr, u64 size) struct stage2_attr_data { kvm_pte_t attr_set; kvm_pte_t attr_clr; - kvm_pte_t pte; + kvm_pte_t attr_old; u32 level; }; @@ -995,7 +995,7 @@ static int stage2_attr_walker(const struct kvm_pgtable_visit_ctx *ctx, return 0; data->level = ctx->level; - data->pte = pte; + data->attr_old |= pte & KVM_PTE_LEAF_ATTRS; pte &= ~data->attr_clr; pte |= data->attr_set; @@ -1004,7 +1004,7 @@ static int stage2_attr_walker(const struct kvm_pgtable_visit_ctx *ctx, * but worst-case the access flag update gets lost and will be * set on the next access instead. */ - if (data->pte != pte) { + if (ctx->old != pte) { /* * Invalidate instruction cache before updating the guest * stage-2 PTE if we are going to add executable permission. @@ -1023,7 +1023,7 @@ static int stage2_attr_walker(const struct kvm_pgtable_visit_ctx *ctx, static int stage2_update_leaf_attrs(struct kvm_pgtable *pgt, u64 addr, u64 size, kvm_pte_t attr_set, - kvm_pte_t attr_clr, kvm_pte_t *orig_pte, + kvm_pte_t attr_clr, kvm_pte_t *attr_old, u32 *level, enum kvm_pgtable_walk_flags flags) { int ret; @@ -1041,11 +1041,12 @@ static int stage2_update_leaf_attrs(struct kvm_pgtable *pgt, u64 addr, if (ret) return ret; - if (orig_pte) - *orig_pte = data.pte; + if (attr_old) + *attr_old = data.attr_old; if (level) *level = data.level; + return 0; } @@ -1058,32 +1059,33 @@ int kvm_pgtable_stage2_wrprotect(struct kvm_pgtable *pgt, u64 addr, u64 size) kvm_pte_t kvm_pgtable_stage2_mkyoung(struct kvm_pgtable *pgt, u64 addr) { - kvm_pte_t pte = 0; + kvm_pte_t attr_old = 0; + stage2_update_leaf_attrs(pgt, addr, 1, KVM_PTE_LEAF_ATTR_LO_S2_AF, 0, - &pte, NULL, 0); + &attr_old, NULL, 0); dsb(ishst); - return pte; + return attr_old; } kvm_pte_t kvm_pgtable_stage2_mkold(struct kvm_pgtable *pgt, u64 addr) { - kvm_pte_t pte = 0; + kvm_pte_t attr_old = 0; stage2_update_leaf_attrs(pgt, addr, 1, 0, KVM_PTE_LEAF_ATTR_LO_S2_AF, - &pte, NULL, 0); + &attr_old, NULL, 0); /* * "But where's the TLBI?!", you scream. * "Over in the core code", I sigh. * * See the '->clear_flush_young()' callback on the KVM mmu notifier. */ - return pte; + return attr_old; } bool kvm_pgtable_stage2_is_young(struct kvm_pgtable *pgt, u64 addr) { - kvm_pte_t pte = 0; - stage2_update_leaf_attrs(pgt, addr, 1, 0, 0, &pte, NULL, 0); - return pte & KVM_PTE_LEAF_ATTR_LO_S2_AF; + kvm_pte_t attr_old = 0; + stage2_update_leaf_attrs(pgt, addr, 1, 0, 0, &attr_old, NULL, 0); + return attr_old & KVM_PTE_LEAF_ATTR_LO_S2_AF; } int kvm_pgtable_stage2_relax_perms(struct kvm_pgtable *pgt, u64 addr, diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index 31d7fa4c7c14..0741f3a8ddca 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -1618,7 +1618,7 @@ bool kvm_age_gfn(struct kvm *kvm, struct kvm_gfn_range *range) kpte = kvm_pgtable_stage2_mkold(kvm->arch.mmu.pgt, range->start << PAGE_SHIFT); pte = __pte(kpte); - return pte_valid(pte) && pte_young(pte); + return pte_young(pte); } bool kvm_test_age_gfn(struct kvm *kvm, struct kvm_gfn_range *range) From patchwork Wed Jan 11 00:02:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 13095779 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2F18DC54EBC for ; Wed, 11 Jan 2023 00:04:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=o+TidGedmU0ozPtiIotrItqxtuQVakW5L3h/zI+Pxfw=; b=3M1/I7r+XMl4eX 1n0VhnwIE1Q4bxeFeQQXehwnHNWayWIU2fvKjotw0sN7yiUdpqiiVW/6mdkHMjTGyQLNIy36h6g3N 6ujdpY+UsckhccnAVhtBHNA7N4ZUdDuequM96Nptj4lSfWBKPJZt8nnQqXVdN0MTz/GMd+j3/uimp EKARy373BuVJQ46CThB5LL5ZpeaDSENtc/kCLZDZZInW/OjaON2aYCtQahlpiIBI+QMsQAiO2HeT9 nq1UfLGZ2wvXnlfOFgZSt29u+AbyydWaE+U2Co7VV/w9mkFVVz8iYPGFak6NF7932oLdFPKTc0KDf rS/XR3IiSckbQyHBVPbg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFOb7-008yFk-4J; Wed, 11 Jan 2023 00:04:05 +0000 Received: from out-116.mta0.migadu.com ([91.218.175.116]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFOaj-008y8d-9a for linux-arm-kernel@lists.infradead.org; Wed, 11 Jan 2023 00:03:43 +0000 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1673395419; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=397Jy7uSB1uDMzXmYRvevSqw1dMvXvfkhIV+co0tmnk=; b=T8V3oIjebb7+PX4tq7GM3laLCNdWilyuSIIRQoLfnJJt2qicUqMjXAHQ0Bcx3evc1Oy5Gk lcdkIZq0LNKrNIK62cstT5UmpKkWkuF/IgStn9JZ8vDB/lw+kXux9QHBA3JCwUWfji15pe 4voQ84VROadNhccb0pAcyPc/qGuHprk= From: Oliver Upton To: Marc Zyngier , James Morse Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, Quentin Perret , Will Deacon , Reiji Watanabe , Oliver Upton Subject: [PATCH 4/5] KVM: arm64: Correctly handle page aging notifiers for unaligned memlsot Date: Wed, 11 Jan 2023 00:02:59 +0000 Message-Id: <20230111000300.2034799-5-oliver.upton@linux.dev> In-Reply-To: <20230111000300.2034799-1-oliver.upton@linux.dev> References: <20230111000300.2034799-1-oliver.upton@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230110_160341_512299_8A312F37 X-CRM114-Status: GOOD ( 20.21 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Userspace is allowed to select any PAGE_SIZE aligned hva to back guest memory. This is even the case with hugepages, although it is a rather suboptimal configuration as PTE level mappings are used at stage-2. The page aging notifiers have an assumption that the spefified range is exactly one page/block of memory, which in the aforementioned case is not necessarily true. All together this leads to a rather obvious kernel WARN when using an unaligned memslot: However, the WARN is only part of the issue as the table walkers visit at most a single leaf PTE. For hugepage-backed memory that is at a suboptimal alignment in the memslot, page aging entirely misses accesses to the hugepage at an offset greater than PAGE_SIZE. Pass through the size of the notifier range to the table walkers and traverse the full range of memory requested. While at it, drop the WARN from before as it is clearly a valid condition. Reported-by: Reiji Watanabe Signed-off-by: Oliver Upton --- arch/arm64/include/asm/kvm_pgtable.h | 24 ++++++++++++++---------- arch/arm64/kvm/hyp/pgtable.c | 8 ++++---- arch/arm64/kvm/mmu.c | 10 ++++++---- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/arch/arm64/include/asm/kvm_pgtable.h b/arch/arm64/include/asm/kvm_pgtable.h index f8f6b4d2735a..81e04a24cc76 100644 --- a/arch/arm64/include/asm/kvm_pgtable.h +++ b/arch/arm64/include/asm/kvm_pgtable.h @@ -584,22 +584,24 @@ int kvm_pgtable_stage2_wrprotect(struct kvm_pgtable *pgt, u64 addr, u64 size); kvm_pte_t kvm_pgtable_stage2_mkyoung(struct kvm_pgtable *pgt, u64 addr); /** - * kvm_pgtable_stage2_mkold() - Clear the access flag in a page-table entry. + * kvm_pgtable_stage2_mkold() - Clear the access flag in a range of page-table + * entries. * @pgt: Page-table structure initialised by kvm_pgtable_stage2_init*(). - * @addr: Intermediate physical address to identify the page-table entry. + * @addr: Intermediate physical address to identify the start of the + * range. * * The offset of @addr within a page is ignored. * - * If there is a valid, leaf page-table entry used to translate @addr, then - * clear the access flag in that entry. + * If there is a valid, leaf page-table entry used to translate the specified + * range, then clear the access flag in that entry. * * Note that it is the caller's responsibility to invalidate the TLB after * calling this function to ensure that the updated permissions are visible * to the CPUs. * - * Return: The old page-table entry prior to clearing the flag, 0 on failure. + * Return: Bitwise-OR of the prior to clearing the flag, 0 on failure. */ -kvm_pte_t kvm_pgtable_stage2_mkold(struct kvm_pgtable *pgt, u64 addr); +kvm_pte_t kvm_pgtable_stage2_mkold(struct kvm_pgtable *pgt, u64 addr, u64 size); /** * kvm_pgtable_stage2_relax_perms() - Relax the permissions enforced by a @@ -622,16 +624,18 @@ int kvm_pgtable_stage2_relax_perms(struct kvm_pgtable *pgt, u64 addr, enum kvm_pgtable_prot prot); /** - * kvm_pgtable_stage2_is_young() - Test whether a page-table entry has the - * access flag set. + * kvm_pgtable_stage2_is_young() - Test whether a range of page-table entries + * have the access flag set. * @pgt: Page-table structure initialised by kvm_pgtable_stage2_init*(). * @addr: Intermediate physical address to identify the page-table entry. + * @size: Size of the range to test. * * The offset of @addr within a page is ignored. * - * Return: True if the page-table entry has the access flag set, false otherwise. + * Return: True if any of the page-table entries within the range have the + * access flag, false otherwise. */ -bool kvm_pgtable_stage2_is_young(struct kvm_pgtable *pgt, u64 addr); +bool kvm_pgtable_stage2_is_young(struct kvm_pgtable *pgt, u64 addr, u64 size); /** * kvm_pgtable_stage2_flush_range() - Clean and invalidate data cache to Point diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c index a3d599e3af60..791f7e81671e 100644 --- a/arch/arm64/kvm/hyp/pgtable.c +++ b/arch/arm64/kvm/hyp/pgtable.c @@ -1067,10 +1067,10 @@ kvm_pte_t kvm_pgtable_stage2_mkyoung(struct kvm_pgtable *pgt, u64 addr) return attr_old; } -kvm_pte_t kvm_pgtable_stage2_mkold(struct kvm_pgtable *pgt, u64 addr) +kvm_pte_t kvm_pgtable_stage2_mkold(struct kvm_pgtable *pgt, u64 addr, u64 size) { kvm_pte_t attr_old = 0; - stage2_update_leaf_attrs(pgt, addr, 1, 0, KVM_PTE_LEAF_ATTR_LO_S2_AF, + stage2_update_leaf_attrs(pgt, addr, size, 0, KVM_PTE_LEAF_ATTR_LO_S2_AF, &attr_old, NULL, 0); /* * "But where's the TLBI?!", you scream. @@ -1081,10 +1081,10 @@ kvm_pte_t kvm_pgtable_stage2_mkold(struct kvm_pgtable *pgt, u64 addr) return attr_old; } -bool kvm_pgtable_stage2_is_young(struct kvm_pgtable *pgt, u64 addr) +bool kvm_pgtable_stage2_is_young(struct kvm_pgtable *pgt, u64 addr, u64 size) { kvm_pte_t attr_old = 0; - stage2_update_leaf_attrs(pgt, addr, 1, 0, 0, &attr_old, NULL, 0); + stage2_update_leaf_attrs(pgt, addr, size, 0, 0, &attr_old, NULL, 0); return attr_old & KVM_PTE_LEAF_ATTR_LO_S2_AF; } diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index 0741f3a8ddca..0b8e2a57f81a 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -1613,21 +1613,23 @@ bool kvm_age_gfn(struct kvm *kvm, struct kvm_gfn_range *range) if (!kvm->arch.mmu.pgt) return false; - WARN_ON(size != PAGE_SIZE && size != PMD_SIZE && size != PUD_SIZE); - kpte = kvm_pgtable_stage2_mkold(kvm->arch.mmu.pgt, - range->start << PAGE_SHIFT); + range->start << PAGE_SHIFT, + size); pte = __pte(kpte); return pte_young(pte); } bool kvm_test_age_gfn(struct kvm *kvm, struct kvm_gfn_range *range) { + u64 size = (range->end - range->start) << PAGE_SHIFT; + if (!kvm->arch.mmu.pgt) return false; return kvm_pgtable_stage2_is_young(kvm->arch.mmu.pgt, - range->start << PAGE_SHIFT); + range->start << PAGE_SHIFT, + size); } phys_addr_t kvm_mmu_get_httbr(void) From patchwork Wed Jan 11 00:03:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 13095780 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F1911C54EBC for ; Wed, 11 Jan 2023 00:05:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=nVXG5TZCbXbx5I8Lc0nojTHIZGEMzkbUASXaNBuJ8+g=; b=vN0cRsbHNOfDym BPPe9pEdsYM7U1Bqes3CNJkhHVkDK9f2yZSl4jPxrKWcmFk9twljewiNT6MHZ2LFo5X1v4hYbUOZY g4hahL1nIeN20PpVdeIQOQr1jUfvvrl7ACCTuXRwyK9Unwf6XZCXmNEGObCcnD5h5ATRFdS+LvR9r N+bKu4MHo1zwEGH/Y4tQOBtRRvGr5xRh2eV+jWPi05VPMH9H67z6Z2BjVQLmxQSx5ym4w8aqm51o2 soseFIoTthdjruEYAvth6pF/PA+HX1oucALyk42YgrCvTXDO9+l5cGAq9Nt7hophKhdHyRI7wURPr yLpoJbnwzltcqwC0aXdg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFObG-008yJo-94; Wed, 11 Jan 2023 00:04:14 +0000 Received: from out-144.mta0.migadu.com ([2001:41d0:1004:224b::90]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFOan-008y9U-22 for linux-arm-kernel@lists.infradead.org; Wed, 11 Jan 2023 00:03:46 +0000 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1673395421; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=U9eN0QijdqjixC9XiiLLRZwsrIMqmoYrpNGMUYRYtVg=; b=LJOWuMn19pWEgAL4w4hEMCcg67W9vohKbKmHWboakIgUdjI5y+jCNDZhBxkqeDDnG0GU8j 8wAvDtZQsI3oJQRFph8I5DyQX95ZeL5kXX9WZgqwUJiU794zk1DVkslNfNIapFkM3F0Ri9 PxSPCh3prO2G9VIktqYxBoLFk9+qwFk= From: Oliver Upton To: Marc Zyngier , James Morse Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, Quentin Perret , Will Deacon , Reiji Watanabe , Oliver Upton Subject: [PATCH 5/5] KVM: arm64: Consistently use KVM's types/helpers in kvm_age_gfn() Date: Wed, 11 Jan 2023 00:03:00 +0000 Message-Id: <20230111000300.2034799-6-oliver.upton@linux.dev> In-Reply-To: <20230111000300.2034799-1-oliver.upton@linux.dev> References: <20230111000300.2034799-1-oliver.upton@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230110_160345_257547_D2F7B906 X-CRM114-Status: GOOD ( 11.44 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org There's no real need for indirection through the kernel's PTE types here. Add a new helper to test if the access flag is set on a PTE and use it to roll over kvm_age_gfn() to only using kvm_pte_t. No functional change intended. Signed-off-by: Oliver Upton --- arch/arm64/include/asm/kvm_pgtable.h | 5 +++++ arch/arm64/kvm/hyp/pgtable.c | 2 +- arch/arm64/kvm/mmu.c | 12 +++++------- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/arch/arm64/include/asm/kvm_pgtable.h b/arch/arm64/include/asm/kvm_pgtable.h index 81e04a24cc76..a81cd1ea64cb 100644 --- a/arch/arm64/include/asm/kvm_pgtable.h +++ b/arch/arm64/include/asm/kvm_pgtable.h @@ -86,6 +86,11 @@ static inline bool kvm_pte_valid(kvm_pte_t pte) return pte & KVM_PTE_VALID; } +static inline bool kvm_pte_young(kvm_pte_t pte) +{ + return pte & KVM_PTE_LEAF_ATTR_LO_S2_AF; +} + static inline u64 kvm_pte_to_phys(kvm_pte_t pte) { u64 pa = pte & KVM_PTE_ADDR_MASK; diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c index 791f7e81671e..19f5094dfd93 100644 --- a/arch/arm64/kvm/hyp/pgtable.c +++ b/arch/arm64/kvm/hyp/pgtable.c @@ -1085,7 +1085,7 @@ bool kvm_pgtable_stage2_is_young(struct kvm_pgtable *pgt, u64 addr, u64 size) { kvm_pte_t attr_old = 0; stage2_update_leaf_attrs(pgt, addr, size, 0, 0, &attr_old, NULL, 0); - return attr_old & KVM_PTE_LEAF_ATTR_LO_S2_AF; + return kvm_pte_young(attr_old); } int kvm_pgtable_stage2_relax_perms(struct kvm_pgtable *pgt, u64 addr, diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index 0b8e2a57f81a..3297475dcfcc 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -1607,17 +1607,15 @@ bool kvm_set_spte_gfn(struct kvm *kvm, struct kvm_gfn_range *range) bool kvm_age_gfn(struct kvm *kvm, struct kvm_gfn_range *range) { u64 size = (range->end - range->start) << PAGE_SHIFT; - kvm_pte_t kpte; - pte_t pte; + kvm_pte_t pte; if (!kvm->arch.mmu.pgt) return false; - kpte = kvm_pgtable_stage2_mkold(kvm->arch.mmu.pgt, - range->start << PAGE_SHIFT, - size); - pte = __pte(kpte); - return pte_young(pte); + pte = kvm_pgtable_stage2_mkold(kvm->arch.mmu.pgt, + range->start << PAGE_SHIFT, + size); + return kvm_pte_young(pte); } bool kvm_test_age_gfn(struct kvm *kvm, struct kvm_gfn_range *range)