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 613F3ECE593 for ; Tue, 10 Sep 2024 00:20:21 +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=3qDUKZkW1qm/U7nIsNHl6u/vxYb3LmdiiRvhpMXyqBg=; b=vU/T5jhp2JkA4aLQXSEuY+/Boq iPHRExq2E08UoxzgDg1wDRp8FbVHw1k4j25QkjKNEkKOHYz/3BtpeKaJE3JF+u+lEqMpYhvupYVO4 xS4+vFGxWNHmWNwj6iMsOtUDThGPkRayqEDveX44Q72DcG4edCw5ikjo7ihqR7+AjNCTrRp9OhF2L RfYRFoBnGk04g/Veoev7xqxnAINoDkkj47PXH4UJZqeG/TPhoFdcsazK5IFV8H57lC1rbCI4Wmt6z JgqxH1plZOU3p31/VSmKn/ok300TFmT2MfilDOv2MQZfpUMWo8u5aieYTF6TYfZermpvDCcZ5e/p9 8JiSy1sA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1snoc6-00000003fiY-0WiO; Tue, 10 Sep 2024 00:20:10 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1snoal-00000003fXP-3V2N for linux-arm-kernel@lists.infradead.org; Tue, 10 Sep 2024 00:18:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725927526; 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=3qDUKZkW1qm/U7nIsNHl6u/vxYb3LmdiiRvhpMXyqBg=; b=F2eut/JvZD+gEEtBVx8ANfa8sBe7GAaNJa1PVxtjBLKac9RjBDYt19LxTO4bIppg5v3C7J WCjipJqq1R4b7mcX+kdJaqP8hSnYZu3SxB7gSq+6DlLhFD1htJiJ6D9PEPAbf7vaCgi8QI OsY7kNCxvkCv1t6mHIKpuwcsEM2gp2c= 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-9-7ELQxtQRNwywn5yEJNCEAw-1; Mon, 09 Sep 2024 20:18:43 -0400 X-MC-Unique: 7ELQxtQRNwywn5yEJNCEAw-1 Received: by mail-pf1-f200.google.com with SMTP id d2e1a72fcca58-718e82769aeso373551b3a.0 for ; Mon, 09 Sep 2024 17:18:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725927522; x=1726532322; 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=3qDUKZkW1qm/U7nIsNHl6u/vxYb3LmdiiRvhpMXyqBg=; b=IZcupdgz4dHUpK2kGrCcwcZ9/OjZmgsis41pRR/QFGgcRX7Bv4R7NwJvuxJ1KRUOS7 /HvmDck5/5R2oYgWO6Oi8fPymIsY4DyGO3xf89qa6UwtuKsOY1TWQbX5bSgGAC7QJWKm JzJJN6adBvlAe6DbrmOrpbFZRnUG9Hi6p46tX4+4B/t/4YekLNYC9MZYpvWQHCzFT8gA AnaPtHCxXzq/lbJHgzyGxqEt8/ARA55DdouOjm5sh4+PrWlGkwSsowi0cuMjYVCT3WD/ Be2wA6d/L7GOANK4n9r1PwA04tKqcBcTYDLqyp4MDjA9J/7XnPNBb3uswAX9LdrAI5R0 cS2w== X-Forwarded-Encrypted: i=1; AJvYcCX6StL5w+HklnqGohoZU5AdWXhsROAA5KnR1A5C/I0nnhwM9DVuzySPApewOpK9DP8mQ1qd8CUQv/uUsqsxxplU@lists.infradead.org X-Gm-Message-State: AOJu0Yw8MqataUoASuzcwLGBx8x+mTqq48B3MaO4CYUFypoRNySknrVw P/ksQNCBGHMIfSbNaLiTJGUaxSLIkkyLMlHy9jdDr9hFr+MU19Fm1cT9nrGLdqNzRx6YZ8Tkre0 YcLqKqn+mEPte3DEUAr4c2Zgoi5apHGPTTW1dpv3zn4fgw1Xh37h/iGMA+rJLG6ggEt8b8YTN X-Received: by 2002:a05:6a00:3cc4:b0:718:d7de:3be2 with SMTP id d2e1a72fcca58-718e33a0050mr14892308b3a.14.1725927521920; Mon, 09 Sep 2024 17:18:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHyd0cypr7QA7LSQQ0FAqADYQZb+J27E549rmhRMytoKbFbGfFE8ni5SsRVpLPAZanhv86dsg== X-Received: by 2002:a05:6a00:3cc4:b0:718:d7de:3be2 with SMTP id d2e1a72fcca58-718e33a0050mr14892272b3a.14.1725927521353; Mon, 09 Sep 2024 17:18:41 -0700 (PDT) Received: from [192.168.68.54] ([103.210.27.31]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7190909222bsm284268b3a.115.2024.09.09.17.18.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 09 Sep 2024 17:18:40 -0700 (PDT) Message-ID: Date: Tue, 10 Sep 2024 10:18:31 +1000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 06/19] arm64: realm: Query IPA size from the RMM 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-7-steven.price@arm.com> From: Gavin Shan In-Reply-To: <20240819131924.372366-7-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_171847_993779_F7C953D8 X-CRM114-Status: GOOD ( 18.57 ) 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: > The top bit of the configured IPA size is used as an attribute to > control whether the address is protected or shared. Query the > configuration from the RMM to assertain which bit this is. > > Co-developed-by: Suzuki K Poulose > Signed-off-by: Suzuki K Poulose > Signed-off-by: Steven Price > --- > Changes since v4: > * Make PROT_NS_SHARED check is_realm_world() to reduce impact on > non-CCA systems. > Changes since v2: > * Drop unneeded extra brackets from PROT_NS_SHARED. > * Drop the explicit alignment from 'config' as struct realm_config now > specifies the alignment. > --- > arch/arm64/include/asm/pgtable-prot.h | 4 ++++ > arch/arm64/kernel/rsi.c | 8 ++++++++ > 2 files changed, 12 insertions(+) > One nit below. Reviewed-by: Gavin Shan > diff --git a/arch/arm64/include/asm/pgtable-prot.h b/arch/arm64/include/asm/pgtable-prot.h > index b11cfb9fdd37..5e578274a3b7 100644 > --- a/arch/arm64/include/asm/pgtable-prot.h > +++ b/arch/arm64/include/asm/pgtable-prot.h > @@ -68,8 +68,12 @@ > > #include > #include > +#include > > extern bool arm64_use_ng_mappings; > +extern unsigned long prot_ns_shared; > + > +#define PROT_NS_SHARED (is_realm_world() ? prot_ns_shared : 0) > > #define PTE_MAYBE_NG (arm64_use_ng_mappings ? PTE_NG : 0) > #define PMD_MAYBE_NG (arm64_use_ng_mappings ? PMD_SECT_NG : 0) > diff --git a/arch/arm64/kernel/rsi.c b/arch/arm64/kernel/rsi.c > index 128a9a05a96b..e968a5c9929e 100644 > --- a/arch/arm64/kernel/rsi.c > +++ b/arch/arm64/kernel/rsi.c > @@ -8,6 +8,11 @@ > #include > #include > > +struct realm_config config; > + > +unsigned long prot_ns_shared; > +EXPORT_SYMBOL(prot_ns_shared); > + > DEFINE_STATIC_KEY_FALSE_RO(rsi_present); > EXPORT_SYMBOL(rsi_present); > > @@ -72,6 +77,9 @@ void __init arm64_rsi_init(void) > return; > if (!rsi_version_matches()) > return; > + if (rsi_get_realm_config(&config)) > + return; > + prot_ns_shared = BIT(config.ipa_bits - 1); > > static_branch_enable(&rsi_present); > } Nit: It's probably worthy to warn on errors returned from rsi_get_realm_config(), It's hard to debug and follow if it fails silently. Thanks, Gavin