From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47006C433DF for ; Thu, 30 Jul 2020 15:38:46 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 192742082E for ; Thu, 30 Jul 2020 15:38:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="KSCcfgUc"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="xVE1R4My" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 192742082E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=xC828UBUAA3zAkw7/iPlLyK/hyI6yvV7ynuNDCqUJQM=; b=KSCcfgUck6O8eOCxBzlqVWHC9 KEv4xYpHL3BsYvo+Py1HN1c7Ou5mGRmutv+DOYs/9wJqIC4mx/vvhqPenVzmKqSc/tz1lt41bODet zrrwWFMBlgNIVic1Xf5YJYtLq8LG0pr8iEqfi21S/QsyiJi98Q02UsWWQKp3vh8/nxhqdsghJNGgU VP6MhSkxztOAdDO3+LGdLMm4lQ4JNVOjxxfrVewMM9HDh0B034jVOd7DlQd7oLz3p/RoNHJ09Bhrt S6CdE4j3eJ04RvDudpwZkNzQ7Aey4Xvu8J0nini0TO3ZrovAN+5D5PDTiarrdFbkI0D/2ta+chiMq PE5XWB3fw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k1AbY-0002YX-N0; Thu, 30 Jul 2020 15:36:24 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k1AZu-0001ww-Fe for linux-arm-kernel@lists.infradead.org; Thu, 30 Jul 2020 15:34:44 +0000 Received: from localhost.localdomain (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 59BFE2082E; Thu, 30 Jul 2020 15:34:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596123281; bh=DwM1hbt8coZsE1uiYZtal06l3PSCMfgsmt7mKWgFqcM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xVE1R4MySAp3LOSsLwMf7Z079vN/+vhDDYEu6N7/kSgwB39+Gn/NOcqsWYUN/aEjZ Bo3PEGSa0biyj3rN/bkCziHjkISEbQR8jZEcMBZs/qcBRos/Gsy2DQdSLWu5BgmXet yhuKAwUO3GSa2LLVepeLNM6qKMdlfXn6zSAga23I= From: Will Deacon To: kvmarm@lists.cs.columbia.edu Subject: [PATCH 11/20] KVM: arm64: Add support for stage-2 write-protect in generic page-table Date: Thu, 30 Jul 2020 16:33:57 +0100 Message-Id: <20200730153406.25136-12-will@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200730153406.25136-1-will@kernel.org> References: <20200730153406.25136-1-will@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200730_113442_689517_E24B1268 X-CRM114-Status: GOOD ( 14.62 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kernel-team@android.com, Suzuki Poulose , Marc Zyngier , Quentin Perret , James Morse , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Quentin Perret Add a stage-2 wrprotect() operation to the generic page-table code. Cc: Marc Zyngier Signed-off-by: Quentin Perret Signed-off-by: Will Deacon --- arch/arm64/include/asm/kvm_pgtable.h | 15 +++++++++++++++ arch/arm64/kvm/pgtable.c | 6 ++++++ 2 files changed, 21 insertions(+) diff --git a/arch/arm64/include/asm/kvm_pgtable.h b/arch/arm64/include/asm/kvm_pgtable.h index 7bc55e874a90..ce90432ec6b9 100644 --- a/arch/arm64/include/asm/kvm_pgtable.h +++ b/arch/arm64/include/asm/kvm_pgtable.h @@ -155,6 +155,21 @@ int kvm_pgtable_stage2_map(void *cookie, u64 addr, u64 size, u64 phys, */ int kvm_pgtable_stage2_unmap(void *cookie, u64 addr, u64 size); +/** + * kvm_pgtable_stage2_wrprotect() - Write-protect guest stage-2 address range + * without TLB invalidation. + * @cookie: Opaque cookie allocated by kvm_pgtable_stage2_alloc_cookie(). + * @addr: Intermediate physical address from which to write-protect, + * @size: Size of the range. + * + * 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: 0 on success, negative error code on failure. + */ +int kvm_pgtable_stage2_wrprotect(void *cookie, u64 addr, u64 size); + /** * kvm_pgtable_stage2_mkyoung() - Set the access flag in a page-table entry. * @cookie: Opaque cookie allocated by kvm_pgtable_stage2_alloc_cookie(). diff --git a/arch/arm64/kvm/pgtable.c b/arch/arm64/kvm/pgtable.c index af15282d3df9..52cb3d5f156e 100644 --- a/arch/arm64/kvm/pgtable.c +++ b/arch/arm64/kvm/pgtable.c @@ -764,6 +764,12 @@ static int stage2_update_leaf_attrs(struct kvm_pgtable *pgt, u64 addr, return 0; } +int kvm_pgtable_stage2_wrprotect(void *cookie, u64 addr, u64 size) +{ + return stage2_update_leaf_attrs(cookie, addr, size, 0, + KVM_PTE_LEAF_ATTR_LO_S2_S2AP_W, NULL); +} + kvm_pte_t kvm_pgtable_stage2_mkyoung(void *cookie, u64 addr) { kvm_pte_t pte = 0; -- 2.28.0.rc0.142.g3c755180ce-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel