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.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 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 ACB0AC433E7 for ; Thu, 3 Sep 2020 04:48:56 +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 7C51220758 for ; Thu, 3 Sep 2020 04:48:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Kbh8P2jz"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="dkopGIse" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7C51220758 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com 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-Type: Content-Transfer-Encoding:Cc:Reply-To:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=GVfEtxYGZjZOLLA+X+uS3DGj1dkjOkFSzo8Rq8XNZ0M=; b=Kbh8P2jznToXik jA4y9htynPDEYJfQ0FzqzNP7ooxRMlHjSB6dCwCHqtCEm08gv8kIOyyMOrAVXI1FyxrNMrX8Q4RQI Sjf05OJeZuXxHE6Z+omged44iMsev1mJ52uVLtONd7Cr05FzxmnX510kE6ilp6JcZSA3wu54nrPuu Cu/KIQFzfe5NMkyHx1fo1vRgc6FI5Jb/MpRqM37kboe8iH52xhndwfx5yWxoIIYO4UUo4Ku8a6fxI qrINbnDpqBB6G14aRjTiKH6/6sCROM1ZwVt4Y/Hr48PMPVswahDDjeOOjU7oJwHJ6vdsZeR05fTli SgenKkErXIkK74CMNQwA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kDh9u-0004zc-AM; Thu, 03 Sep 2020 04:47:38 +0000 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kDh9r-0004zD-CB for linux-arm-kernel@lists.infradead.org; Thu, 03 Sep 2020 04:47:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599108454; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3Ii4iCvgxDZT75qhYiW/32ZMtqw1Jk0DnTURd8h9mAE=; b=dkopGIsevU5Hsu2xANlUyXL0fHOsuevrSte4GGK6vXklC2gNAnyA+tZQJMqiZdoUcNci7n 2rr0YtGuvxDVkCR+xZC6vuwKfJYAFf3V0skIu3lht5mdf+aiz3KQSEC+opZfkSq6q046sx RqdqE8whU+RaJiQ1m2J9CX7bNSvay3Y= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-495-HBghU85tO7ewevn4Bdy59g-1; Thu, 03 Sep 2020 00:47:33 -0400 X-MC-Unique: HBghU85tO7ewevn4Bdy59g-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E54932FD01; Thu, 3 Sep 2020 04:47:30 +0000 (UTC) Received: from [10.64.54.159] (vpn2-54-159.bne.redhat.com [10.64.54.159]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 86FA85D9CC; Thu, 3 Sep 2020 04:47:28 +0000 (UTC) Subject: Re: [PATCH v3 12/21] KVM: arm64: Add support for stage-2 write-protect in generic page-table To: Will Deacon , kvmarm@lists.cs.columbia.edu References: <20200825093953.26493-1-will@kernel.org> <20200825093953.26493-13-will@kernel.org> From: Gavin Shan Message-ID: <6808aab5-3d50-6233-6077-6813ab3abdab@redhat.com> Date: Thu, 3 Sep 2020 14:47:25 +1000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.0 MIME-Version: 1.0 In-Reply-To: <20200825093953.26493-13-will@kernel.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=gshan@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200903_004735_481663_9E6797AB X-CRM114-Status: GOOD ( 21.18 ) 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: , Reply-To: Gavin Shan Cc: Suzuki Poulose , Marc Zyngier , Quentin Perret , James Morse , Catalin Marinas , kernel-team@android.com, linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Will, On 8/25/20 7:39 PM, Will Deacon wrote: > 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 > --- Reviewed-by: Gavin Shan > arch/arm64/include/asm/kvm_pgtable.h | 15 +++++++++++++++ > arch/arm64/kvm/hyp/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 ae56534f87a0..0c96b78d791d 100644 > --- a/arch/arm64/include/asm/kvm_pgtable.h > +++ b/arch/arm64/include/asm/kvm_pgtable.h > @@ -173,6 +173,21 @@ int kvm_pgtable_stage2_map(struct kvm_pgtable *pgt, u64 addr, u64 size, > */ > int kvm_pgtable_stage2_unmap(struct kvm_pgtable *pgt, u64 addr, u64 size); > > +/** > + * kvm_pgtable_stage2_wrprotect() - Write-protect guest stage-2 address range > + * without TLB invalidation. > + * @pgt: Page-table structure initialised by kvm_pgtable_stage2_init(). > + * @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(struct kvm_pgtable *pgt, u64 addr, u64 size); > + > /** > * kvm_pgtable_stage2_mkyoung() - Set the access flag in a page-table entry. > * @pgt: Page-table structure initialised by kvm_pgtable_stage2_init(). > diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c > index 30713eb773e0..c218651f8eba 100644 > --- a/arch/arm64/kvm/hyp/pgtable.c > +++ b/arch/arm64/kvm/hyp/pgtable.c > @@ -726,6 +726,12 @@ static int stage2_update_leaf_attrs(struct kvm_pgtable *pgt, u64 addr, > return 0; > } > > +int kvm_pgtable_stage2_wrprotect(struct kvm_pgtable *pgt, u64 addr, u64 size) > +{ > + return stage2_update_leaf_attrs(pgt, addr, size, 0, > + KVM_PTE_LEAF_ATTR_LO_S2_S2AP_W, NULL); > +} > + > kvm_pte_t kvm_pgtable_stage2_mkyoung(struct kvm_pgtable *pgt, u64 addr) > { > kvm_pte_t pte = 0; > Thanks, Gavin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel