From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail03.groups.io (mail03.groups.io [45.79.227.220]) by spool.mail.gandi.net (Postfix) with ESMTPS id C30767803D0 for ; Fri, 12 Apr 2024 15:14:08 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=g7i5SaCzb5YhwdTDHayc38o7di2RknEsYsik9mQsjJ4=; c=relaxed/simple; d=groups.io; h=Received-SPF:Received-SPF:From:To:CC:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:NoDisclaimer:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type; s=20240206; t=1712934847; v=1; b=WQcj5QulvwNYpM8mlbHkZoICTpMHsBLcgTxNmjWUNesCmjc6mWarvLq/Gb2u787RVpmQijV4 6kSRSEqKTCfkmQVLKwd2oZzo6XBs8x8ebR3FUdpIF4bDLpg6NhgrmLefxml6q3SD/ydpFoz4z4S LMo08EDNXGJMtp4z/cN2xgnYs3pRmoRbLgyUCzMBdkkbjiu2kHqsfQ10iSS1NMwJZWIcYMRbbKO IUKWi0T+3pSwkpoHZQCr2E/ob5zGMGSazXzbWwfp2wr9v2OxkaXdswtAbfEsncBkpsqXo2uSEN1 GWFpQ6pKgI7+aj/MICQDv2JB+sHwzphtxPSvwGmCottfQ== X-Received: by 127.0.0.2 with SMTP id mEzLYY7687511xKZCmLB2Gkl; Fri, 12 Apr 2024 08:14:07 -0700 X-Received: from EUR04-DB3-obe.outbound.protection.outlook.com (EUR04-DB3-obe.outbound.protection.outlook.com [40.107.6.61]) by mx.groups.io with SMTP id smtpd.web11.49059.1712934846613421820 for ; Fri, 12 Apr 2024 08:14:06 -0700 X-Received: from AM4PR07CA0027.eurprd07.prod.outlook.com (2603:10a6:205:1::40) by GV2PR08MB9303.eurprd08.prod.outlook.com (2603:10a6:150:e3::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.54; Fri, 12 Apr 2024 15:14:03 +0000 X-Received: from AMS1EPF00000043.eurprd04.prod.outlook.com (2603:10a6:205:1:cafe::2d) by AM4PR07CA0027.outlook.office365.com (2603:10a6:205:1::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7495.9 via Frontend Transport; Fri, 12 Apr 2024 15:14:03 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C X-Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AMS1EPF00000043.mail.protection.outlook.com (10.167.16.40) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7452.22 via Frontend Transport; Fri, 12 Apr 2024 15:14:02 +0000 X-Received: ("Tessian outbound 8c03561b2da6:v313"); Fri, 12 Apr 2024 15:14:02 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: b4e9fdc60d8c5e13 X-CR-MTA-TID: 64aa7808 X-Received: from bd3efc09a16c.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id EE180061-F5B7-4565-91FA-F1BFAAE8BC22.1; Fri, 12 Apr 2024 15:13:51 +0000 X-Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id bd3efc09a16c.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 12 Apr 2024 15:13:51 +0000 X-Received: from DUZP191CA0072.EURP191.PROD.OUTLOOK.COM (2603:10a6:10:4fa::12) by PAXPR08MB7492.eurprd08.prod.outlook.com (2603:10a6:102:2b5::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.56; Fri, 12 Apr 2024 15:13:50 +0000 X-Received: from DU2PEPF00028D08.eurprd03.prod.outlook.com (2603:10a6:10:4fa:cafe::67) by DUZP191CA0072.outlook.office365.com (2603:10a6:10:4fa::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.26 via Frontend Transport; Fri, 12 Apr 2024 15:13:49 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; pr=C X-Received: from nebula.arm.com (40.67.248.234) by DU2PEPF00028D08.mail.protection.outlook.com (10.167.242.168) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7452.22 via Frontend Transport; Fri, 12 Apr 2024 15:13:49 +0000 X-Received: from AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Fri, 12 Apr 2024 15:13:45 +0000 X-Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Fri, 12 Apr 2024 15:13:44 +0000 X-Received: from E114225.Arm.com (10.1.196.56) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Fri, 12 Apr 2024 15:13:44 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , Subject: [edk2-devel] [PATCH v2 44/45] ArmVirtPkg: ArmCcaLib: Cache current world value Date: Fri, 12 Apr 2024 16:13:40 +0100 Message-ID: <20240412151341.16488-5-sami.mujawar@arm.com> In-Reply-To: <20240412151341.16488-1-sami.mujawar@arm.com> References: <20240412151341.16488-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DU2PEPF00028D08:EE_|PAXPR08MB7492:EE_|AMS1EPF00000043:EE_|GV2PR08MB9303:EE_ X-MS-Office365-Filtering-Correlation-Id: b0f794bc-3c7e-40a3-27c9-08dc5b033015 x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: r8Oo1YWWUb43E7ucSS0NuyizBPBfgh4qwkEmx3nzNoDV+bz8LqlSF/o6xTSiyuesLUci2YVMfPVZnkaHwdm90DrOAufViMTF3QRzdWAaKdgjF7+hfdat+fbhKyGAEyx0fDxgWLuiPUbxX/SG7eBBJyVSmXdTtwyhSMDHkDZXTARfcl9PuUCRvav1X/9ZjCG/Q5V6thoQhnDbtIEwhfW41lVR2aCH75lSRCd7j9H+yfmhXh6D0Gu8UBAXUxAUMMNcu56IUMRkD6qz2VIAe+pjQ5US5vfKPwPKnI0K7NQbZZqSVbcFjKZBc6jWoujOc6r1HCIzCKiKzhgCGbRs4iRAw7MoOHj7x0C4gLRfCi5kYTJ7SdvNX9RUE21vyFYJi5HmBAQC8x5oXP6q7oW5wfv8cYbD6q6wicgMHfVJ3TK8yJE6v5ILbziUNT89Q3aZOFlyrEG3/BtIkuQ4gSr/ckeXKo+mmTFiVuOmapwDyH0/HDAaWdpKoZ1WUcqUEMC2jrqQL1+cb4ExFPgDJimJnUzBLj/6b/ZKdB1zniDFqrkiLhRs2VfXFi1aMAGftzT58fXkSCoYMwgtsDHDb4nN970MHYEp3I8Jt8+gr9BXYGE32G5fYyHUqgYx6S6Gn/ikdS9B4U7UCDu/pHbuq/uI3oQo85/+1zFpitmlA5jt+gl6RdrbsKo0UxU7NKwz63XH2oOaFGXyzMBtiVr4+9COUz4B4B3ipPiqYB6ZZTjgqb1Uxhx1KnTjmv7okE4p5Ms+l2Ix X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(36860700004)(1800799015)(376005)(82310400014);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB7492 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AMS1EPF00000043.eurprd04.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: cb7a820d-2b64-462d-9ae9-08dc5b03284e X-Microsoft-Antispam-Message-Info: 9BVjXPDSntH+BNqC1D3JrTz+2ESpbiKOgQ+BSXSYPFQB54xFCmkRBR/o7lkHgDgpoY8NvfgCgy38o2uX6WRxglXNpi5A6/WTsKrGC+NaZm7RAg0G8qVBi7hu1LJIYMf++b28ib2thE3nzfshf0X4xD47uW6DX6vBi3EtJYdqKeNqTgHqbxIRRYS6V21wrtLU+IRkvRRGyNpMtDYxBa+gxy7fW1XoLKwXcAnlSw/+V6f8A+tNmA26AAp8jMoBxO+8FepfqiR95zLKnmAFcwOz9ppsbwkwD20Zn0Atdpj53Eo4k/LdTfPjsJQ8ZlphynLFoXNhIbp3jb8SMHYB1xaiofY/PiBm5qqZic2RcZyP0vgI0Ga0S4ejmYbA0ACLuvqUzNUACvOV+hQglMoI3I1FiDmEu3stoeo1uHlblOvu3tO8xmfOIipuYdCaKZGXoiXbpSh3jIOAjaNICaaaKkMtkSan8tTLq2MZM2RfXsbJhvun0xtpJVZ9p7QSLlxYZ4isn/mJ7CMOMXzozq6GtoxbU27nkFeFM1mllL6gy5lTVytoD8OEDgZhaXV59MzpG39IYZYHVhck06LEDZEMEn8FD+W2UnRtxyqTak2cXTiJZ6x6fPsCtPQs88vmqOrGg1ftFg6+TwJh1c2d31TDQV6i2JJ8mcaM1VW3hB7XS9Tcdin86yqD8Tu0XPhnUrQpBuy4Yj/CL9s6KyTapFO/5adqLDXZ4+I9RuDTTlDLdxC44atBYLZygZ0692TLU3TcFlZl X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2024 15:14:02.8865 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b0f794bc-3c7e-40a3-27c9-08dc5b033015 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AMS1EPF00000043.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR08MB9303 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Fri, 12 Apr 2024 08:14:07 -0700 Resent-From: sami.mujawar@arm.com Reply-To: devel@edk2.groups.io,sami.mujawar@arm.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: JEGLAsqI6neiLMBvYZlshvgDx7686176AA= Content-Type: text/plain X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=WQcj5Qul; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=arm.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.227.220 as permitted sender) smtp.mailfrom=bounce@groups.io IsRealm() probes to check if the code is executing in a Realm context by checking if RME is supported and then issuing a RSI_VERSION command to check it is supported. Instead of calling RSI_VERSION command every time the IsRealm() is called, cache the world value we are running in, to return the value in subsequent calls. Cc: Ard Biesheuvel Cc: Leif Lindholm Cc: Gerd Hoffmann Signed-off-by: Sami Mujawar --- ArmVirtPkg/Library/ArmCcaLib/ArmCcaLib.c | 31 ++++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/ArmVirtPkg/Library/ArmCcaLib/ArmCcaLib.c b/ArmVirtPkg/Library/ArmCcaLib/ArmCcaLib.c index 3abb4dfaf567c635b28ff3a7cd5adea064e02510..67ad2824f1f6a8fe4e1fd3f837300097a68775c7 100644 --- a/ArmVirtPkg/Library/ArmCcaLib/ArmCcaLib.c +++ b/ArmVirtPkg/Library/ArmCcaLib/ArmCcaLib.c @@ -35,23 +35,28 @@ IsRealm ( VOID ) { - RETURN_STATUS Status; - UINT32 UefiImpl; - UINT32 RmmImplLow; - UINT32 RmmImplHigh; + RETURN_STATUS Status; + UINT32 UefiImpl; + UINT32 RmmImplLow; + UINT32 RmmImplHigh; + STATIC BOOLEAN RealmWorld = FALSE; + STATIC BOOLEAN FlagsInitialised = FALSE; - if (ArmHasRme ()) { - Status = RsiGetVersion ( - &UefiImpl, - &RmmImplLow, - &RmmImplHigh - ); - if (!RETURN_ERROR (Status)) { - return TRUE; + if (!FlagsInitialised) { + FlagsInitialised = TRUE; + if (ArmHasRme ()) { + Status = RsiGetVersion ( + &UefiImpl, + &RmmImplLow, + &RmmImplHigh + ); + if (!RETURN_ERROR (Status)) { + RealmWorld = TRUE; + } } } - return FALSE; + return RealmWorld; } /** -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#117714): https://edk2.groups.io/g/devel/message/117714 Mute This Topic: https://groups.io/mt/105484265/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-