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 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 45A06EB64DE for ; Tue, 10 Sep 2024 03:52:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=/I3+YXY+JwS3qdscq18bmJNKDLcufBeHf8bjRwDJT1w=; b=XpJZlsFuKCuPExv1INYL7wFuDz pcPn9VsPLVyxpBTbNOqU+Qj3tnlhSTYKqlpTcC2du0zWLFn4W4N9oLjjI9XIAJ0AE7QK557VcwQ4d q2IDyh9TuLSY1B3g2CE5uNRJcbYQx7rqhKxA1sTZs1TFRNjBJHrb6bIS7JFXC7TYbGeBYrcqXmzQe Z1CuplLFokO8qZzghoUc68ziqzNiiL9wyq2piNL3hjsgCtj1/WHWQ7J09KMMY8bMf8j4KnWux1WF2 753Fwn4hRgpIyRdJ4YKERz7t+1FR+eqL+/yIbxqG56+ZNb0dIxzyUmjOjtSoWJaaP7To3kVbtHy75 CPLXLuoQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1snrvd-000000047Uj-1TU4; Tue, 10 Sep 2024 03:52:33 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1snrub-000000047MN-27mW for linux-arm-kernel@lists.infradead.org; Tue, 10 Sep 2024 03:51:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725940287; h=from:from: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=/I3+YXY+JwS3qdscq18bmJNKDLcufBeHf8bjRwDJT1w=; b=JEFWGGMECG9Wsur0jZmkGEN5a0hJsW3mUJMzV03wSstL8BEjv7CHSLPwHGPBbr+ZlFtDcn SOyxhqKgh3RxhFIQni/9W2vdU9o9rfLbVxFA7b1/03v8pmXyaH9YySnl6uZE1K5P6DxFgm KoRTCLx0rwiPXZSgNRqKmSRsuDqj1CQ= Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-312-fSl-n2a2MYu3UTXITXHPbQ-1; Mon, 09 Sep 2024 23:51:24 -0400 X-MC-Unique: fSl-n2a2MYu3UTXITXHPbQ-1 Received: by mail-pf1-f200.google.com with SMTP id d2e1a72fcca58-7177906db91so5244338b3a.3 for ; Mon, 09 Sep 2024 20:51:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725940283; x=1726545083; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/I3+YXY+JwS3qdscq18bmJNKDLcufBeHf8bjRwDJT1w=; b=IuYbhMA7/YdCFkgHFPFjMiX58DWnftYUUav+qJaOAAUgtS60qIawsbVtV6IfFOewip MLUiRCuYzIEl82OTw+IxGo41MmpFz+mOUd+btebKkl5vU8szfoHTuYELL5UtCRA5HGnm Z+jv+3a3KV/e4RKHS+e++Yl5HihO8QP+1g5jfDCKI0uDu8KnNtrjg7ZDaRaBTJIBMTO2 jvCjGMlzUG6SgZL+XnuHnnflKO40hpU3b8MxMhjM62Rf9/sW2DLG5qZ37p2vjh8t56xs qyn5+JgZnQ+fkswzDlgG2SApnpm7EvmDWsQ31unyGKmcR7VJ9s2sKpi1FZ99D7yszdDn LLLQ== X-Forwarded-Encrypted: i=1; AJvYcCVZ5NyoprprVn6SMg/BkN4H9Q4aq8TG6jrVPzlbv+jnigtyuoWcFqdAGIAnhFeakIYu4hxRchIU+95I+TA/K5iU@lists.infradead.org X-Gm-Message-State: AOJu0Yyo/3LYTHYiOylt8ryarYDxGcJmWtMTcnmpWQMkSO6p3vmOQM2z e6d/MHVJ1f4zUPo7+0+GAzR3wI0W23tiAwKIICXzReV960kpozBdzEuG9SjVXr6NdqpQnlzu4H2 /kR3lS2rL7qIRf2rZZ8z/Ca+E8V3WPMuzbIrGLwXTzRJ6VGsGQ63urfFh+PVXjoWr0kVVFAzK X-Received: by 2002:a05:6a00:17a9:b0:714:20a8:d79f with SMTP id d2e1a72fcca58-718d5e52b97mr16304606b3a.14.1725940282885; Mon, 09 Sep 2024 20:51:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE/d19sKSMFsfHliPT47QFiITi7JaTPVoNF1P6pGKw0CeBAi1klKPcTxxhOABv3xB54UTlCPw== X-Received: by 2002:a05:6a00:17a9:b0:714:20a8:d79f with SMTP id d2e1a72fcca58-718d5e52b97mr16304574b3a.14.1725940282285; Mon, 09 Sep 2024 20:51:22 -0700 (PDT) Received: from [192.168.68.54] ([103.210.27.31]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71908feb36dsm462585b3a.58.2024.09.09.20.51.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 09 Sep 2024 20:51:21 -0700 (PDT) Message-ID: Date: Tue, 10 Sep 2024 13:51:12 +1000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 07/19] arm64: rsi: Add support for checking whether an MMIO is protected To: Steven Price , kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: Catalin Marinas , Marc Zyngier , Will Deacon , James Morse , Oliver Upton , Suzuki K Poulose , Zenghui Yu , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Joey Gouly , Alexandru Elisei , Christoffer Dall , Fuad Tabba , linux-coco@lists.linux.dev, Ganapatrao Kulkarni , Shanker Donthineni , Alper Gun References: <20240819131924.372366-1-steven.price@arm.com> <20240819131924.372366-8-steven.price@arm.com> From: Gavin Shan In-Reply-To: <20240819131924.372366-8-steven.price@arm.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240909_205129_654682_A2C960F5 X-CRM114-Status: GOOD ( 23.19 ) 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 On 8/19/24 11:19 PM, Steven Price wrote: > From: Suzuki K Poulose > > On Arm CCA, with RMM-v1.0, all MMIO regions are shared. However, in > the future, an Arm CCA-v1.0 compliant guest may be run in a lesser > privileged partition in the Realm World (with Arm CCA-v1.1 Planes > feature). In this case, some of the MMIO regions may be emulated > by a higher privileged component in the Realm world, i.e, protected. > > Thus the guest must decide today, whether a given MMIO region is shared > vs Protected and create the stage1 mapping accordingly. On Arm CCA, this > detection is based on the "IPA State" (RIPAS == RIPAS_IO). Provide a > helper to run this check on a given range of MMIO. > > Also, provide a arm64 helper which may be hooked in by other solutions. > > Signed-off-by: Suzuki K Poulose > Signed-off-by: Steven Price > --- > New patch for v5 > --- > arch/arm64/include/asm/io.h | 8 ++++++++ > arch/arm64/include/asm/rsi.h | 3 +++ > arch/arm64/include/asm/rsi_cmds.h | 21 +++++++++++++++++++++ > arch/arm64/kernel/rsi.c | 26 ++++++++++++++++++++++++++ > 4 files changed, 58 insertions(+) > > diff --git a/arch/arm64/include/asm/io.h b/arch/arm64/include/asm/io.h > index 1ada23a6ec19..a6c551c5e44e 100644 > --- a/arch/arm64/include/asm/io.h > +++ b/arch/arm64/include/asm/io.h > @@ -17,6 +17,7 @@ > #include > #include > #include > +#include > > /* > * Generic IO read/write. These perform native-endian accesses. > @@ -318,4 +319,11 @@ extern bool arch_memremap_can_ram_remap(resource_size_t offset, size_t size, > unsigned long flags); > #define arch_memremap_can_ram_remap arch_memremap_can_ram_remap > > +static inline bool arm64_is_iomem_private(phys_addr_t phys_addr, size_t size) > +{ > + if (unlikely(is_realm_world())) > + return arm64_rsi_is_protected_mmio(phys_addr, size); > + return false; > +} > + I guess it might be better to unify the function names here. The name of arm64_is_iomem_private() indicates the IO region is private, while the name of arm64_rsi_is_protected_mmio() indicates the IO region is protected. I think it would be nice to rename arm64_is_iomem_private() arm64_is_protected_iomem(), or rename arm64_rsi_is_protected_mmio() to arm64_rsi_is_private_iomem(). Thanks, Gavin