From patchwork Fri Jan 27 11:40:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13118653 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 9A3DEC38142 for ; Fri, 27 Jan 2023 12:49:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=LDElpxnInrH3YTF/Cc0CWVIF+RA4GgHFBr1Eaib9I/U=; b=nb57L+Si3Tv9Ks 0SytvK0o6koxKi3f14bWQKgKNAGmQft3dG15afJdCrzUdZi8s9YFnUjILizousRdSYQQco9P/kOAu +s2vEBNAoHc4lDPgtyfRyBtMEAeqUQZLy+d1l4MEFGmYHLB6VJrklcSHwVOqQ/VXllSVAL1NuFdLE Fkj56CIR0DzrBHyHYrDwI3U2W1BdG/liHbgOUyRprmT/kqq81oijlDFnoUJTI8vnr/vTop1h2Hv3n 2bNSNkcx/H8MQ19F8ZyAXFng6plaY/Lh4JmOD51mrpau30mQk+4SxVSoyvHWblxZdF9fGSKgACb2g alSfdWuuKPIyE+od10Rg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLO8d-00EhPr-Pa; Fri, 27 Jan 2023 12:47:29 +0000 Received: from mail-vi1eur04on2043.outbound.protection.outlook.com ([40.107.8.43] helo=EUR04-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN9Z-00EEsY-Mn for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:44:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dAthAYOVywOx8lXe0h46x7ZB6wNi2URhTTiXJIcBscU=; b=33gJpoAbHMpJgShtK36NvshIaiJwXLMHJRWF/7XkPzEN5LMpvoAg51lA8KbjuVpPTMWBz6IcoUy7kJOABQ7HO0gjf+5X/J06znkx5cJIqi7gQz4PkGQu26VriCeSMlAv/dutdE1XVtHrWBNIOEriEVbnmEYk7ASKKJp/mBxjhgw= Received: from DUZPR01CA0026.eurprd01.prod.exchangelabs.com (2603:10a6:10:46b::20) by GV2PR08MB9925.eurprd08.prod.outlook.com (2603:10a6:150:c3::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23; Fri, 27 Jan 2023 11:44:04 +0000 Received: from DBAEUR03FT005.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:46b:cafe::fd) by DUZPR01CA0026.outlook.office365.com (2603:10a6:10:46b::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.34 via Frontend Transport; Fri, 27 Jan 2023 11:44:04 +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 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT005.mail.protection.outlook.com (100.127.142.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.21 via Frontend Transport; Fri, 27 Jan 2023 11:44:04 +0000 Received: ("Tessian outbound b1d3ffe56e73:v132"); Fri, 27 Jan 2023 11:44:03 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 79fec1a3b4157ab0 X-CR-MTA-TID: 64aa7808 Received: from 9134af7da11f.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id E8CDC639-88BD-455C-B67E-8AC8E24ADBE9.1; Fri, 27 Jan 2023 11:41:29 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 9134af7da11f.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 27 Jan 2023 11:41:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Nmq85NsRTvJ2QTNZU5yQQMc+1XrRAE/uDbfZf4t7WFttH5OiOofMK5XDqtSn0SA/HxnBq4ZZREi8wIrOyABIAaRWNBVK5tSG+uZWfIWfhbCTDFfX/Zg2+DlqetX1BgkaQn50CIbNy5LzXf41wl7lRWHZ5Fyrz59Y+7lrAOgJwp5cxOeZRN1Lxka8MQHh7fZCB8qhEDeMh/qCNMbPow/9WZm5AKL35DkX/eJet3TNNQppLk8pt9dFSt5C84TddfjPPMGXs86T4+wvPqjQM+QDAMx0xAlHYVEfDK7aI1XXBFXc4SsTG9xipNeAh36HOrS31rpKdCkGOvBW+N5hV/Q8tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=dAthAYOVywOx8lXe0h46x7ZB6wNi2URhTTiXJIcBscU=; b=S3FG+yu+FRUfUQnX2D3d8jTBGn7N2o5tt/lzRllOZSgzb5UspJSj28lKSTJUFkdZC4G/mLUMbjmPWgJyda28pe5T1wzS1xqmsvV4drWFW+AkhxvUX4Z6EV4YrOdkuDJgROXoyOLl9+kg0rOuV5joUmbnZhm7YPeEf8DbGUHvXJ6J6fNoKSMXL5Z8vNqX0aDDxx7ureDgXzYVLt3hKbmN/8yiqT6YnH2HiyQqp0s/YmcYr5MZseyQ6ULeiVwmOEg2/CSV7z1lWkRGmtJwOs/mdVIT/iVOJXL87EKKudIa4ZpCT7K/hTzFU110wvGq0v5/NYyJfN6UzXMpIt4bhg3adQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=linux.dev smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dAthAYOVywOx8lXe0h46x7ZB6wNi2URhTTiXJIcBscU=; b=33gJpoAbHMpJgShtK36NvshIaiJwXLMHJRWF/7XkPzEN5LMpvoAg51lA8KbjuVpPTMWBz6IcoUy7kJOABQ7HO0gjf+5X/J06znkx5cJIqi7gQz4PkGQu26VriCeSMlAv/dutdE1XVtHrWBNIOEriEVbnmEYk7ASKKJp/mBxjhgw= Received: from AS9PR06CA0224.eurprd06.prod.outlook.com (2603:10a6:20b:45e::21) by AS8PR08MB10149.eurprd08.prod.outlook.com (2603:10a6:20b:63f::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33; Fri, 27 Jan 2023 11:41:27 +0000 Received: from AM7EUR03FT049.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:45e:cafe::17) by AS9PR06CA0224.outlook.office365.com (2603:10a6:20b:45e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23 via Frontend Transport; Fri, 27 Jan 2023 11:41:27 +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 Received: from nebula.arm.com (40.67.248.234) by AM7EUR03FT049.mail.protection.outlook.com (100.127.140.234) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6043.23 via Frontend Transport; Fri, 27 Jan 2023 11:41:27 +0000 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.16; Fri, 27 Jan 2023 11:41:22 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) 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.16; Fri, 27 Jan 2023 11:41:21 +0000 Received: from e124191.cambridge.arm.com (10.1.197.45) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Fri, 27 Jan 2023 11:41:16 +0000 From: Joey Gouly To: Andrew Jones , , CC: , Alexandru Elisei , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Suzuki K Poulose , "Thomas Huth" , Will Deacon , Zenghui Yu , , , , Subject: [RFC kvm-unit-tests 01/27] lib/string: include stddef.h for size_t Date: Fri, 27 Jan 2023 11:40:42 +0000 Message-ID: <20230127114108.10025-2-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230127114108.10025-1-joey.gouly@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127114108.10025-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT049:EE_|AS8PR08MB10149:EE_|DBAEUR03FT005:EE_|GV2PR08MB9925:EE_ X-MS-Office365-Filtering-Correlation-Id: 916313e3-5299-4dd1-c0f8-08db005bca66 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: onWF71zoO6duUEy+orjL4HaxS7SZPO7QtYxVx46ihrlGO+YyVonwfIlTIu00ZAPHMs7YkA3E6vU9GnqqdU27eMrSPYu/x1wCRnudyHy5gM/gZ8W7/GgTP5530FbyNkMiccVtwRyU2fvbqEiy9RK1HPX2oYrwhFWhi005jQEdRWSrf3HGKCulEBesNQpa1HUJ7IX5eWG7Gjnj8oRYS1cVcnMrKM31Iy7uzvnvw0iQ0v9TF90z8j0TzhNxvG1sZy363v1rvCg/wb0CjxzQWQhy4k2/B92exKQP8b+gt6aoXdM7pppTWhPHkg4RFXqpeB//gffmF3kcfMNWSFOuJYgMBYiMBGgj7vWdlZOZCsY102gVLqjuSvqkOhWjhiP8fFBdx9vWelXzjr75mW5MFs7PjZeSed0SY3ZfC1ItTa5Hfgexj5m7uCnVXw6HS0MKqzbYGYyfhQe9bVZH3ljQhwkIGpHflS4rq4KlXj+c+GN2Hltz0Ji1LsUkffHEwQr77tNThmnTwWZ0Q6tWJxJWkgiFx9yv0AKf7hlmfY6pcfUhaAK1HW9Ol18oebkFwl8x9HV1Fob94Zuz8Z6ITPJozmg7vhKbT832BIzIpqfqkq9cDh2mf3LI2Rz69J6BJRO7WzFae424vUO7jvYEwraiwCLr80DtcXANe0WX6ud3b5uvawutaZjZy9kr+NJe00cAjQhlePoGZ2ibeu/4qkgzuzuHutcwKkoXLNePSB4mKNvd6xiRUw7Mk9Micf72EgyKR/T7 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:(13230025)(4636009)(376002)(346002)(39860400002)(136003)(396003)(451199018)(40470700004)(46966006)(36840700001)(82740400003)(36756003)(40460700003)(4744005)(82310400005)(356005)(316002)(5660300002)(26005)(7696005)(186003)(8936002)(47076005)(36860700001)(4326008)(40480700001)(2906002)(7416002)(70206006)(70586007)(6666004)(478600001)(81166007)(426003)(336012)(8676002)(44832011)(41300700001)(1076003)(54906003)(2616005)(110136005)(86362001)(2101003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB10149 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT005.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: f5b9ad6e-8f74-4b5f-466a-08db005b6cdd X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: icwNDKIgCLz9quJcCvHJWDAlgoVh12PHIHMD0F7pvmISDZxBdBbt+T1GDFcecwV0JaLZE7PgJnK8OrLuuz+lEi4uK2HdUcF5XPUC/Xnk6KZ7aBvNGMkJhDgTeyysY2+/Tgqdyf9vJzOWyG00J6pkMw23x0FzKTjYK5SRvIT6QbtIBfCkPduHxPMKq2juu91baa0fJTiH9LYTzf/bb9SJsErzKlXeiPZNL3PbMUZs7QOOoTfqh6mhnuyF+eMHEi8bJtyiKz8KCzPMlX6unzMpit2RU9+Y9RSBm04mnj4H82PIFMqQqak9WmdNJipaLGyp29J+itcmeDzkhGBjAg4L71TER/4kWWqNzZPOON8gXqEC2Lige2+nRnPmJzOpwR0FRel90O1RUxrUI/ACS0vKQjjJTICA6seJq8bSAwF7GGHRXG9z5S7E1ZbrEMv+r8W4d7loBeNS4tlBNmxHLObO892hJhgFQr2cHlpOt3SoUlXx2Si0vxG8JlAWkR1afY4ZgYpkqwYfiyEXFm0kZ54fdckCKf7EDUg8nQCy09H29L269CPsdYpBqVa8eE+7vk1QNcYbvxRQbFge9p1csJiwHTRTC4Mt981pHb9GPSHXiRAIHvDO9Yhnc068/KMTbIF0pDw5v2gJNl0GtvVPVeck7jpJwWR5fzVvDiZ6+AHAIiy3OHNjTysbkw7nEc8wtfwwFhUy2OnNSv4yK+m45KlZYfJYP33k8RgC6JtJcfx+ArE= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230025)(4636009)(39860400002)(376002)(396003)(346002)(136003)(451199018)(40470700004)(36840700001)(46966006)(44832011)(2906002)(4744005)(426003)(336012)(36860700001)(41300700001)(8936002)(5660300002)(478600001)(1076003)(107886003)(2616005)(26005)(186003)(8676002)(6666004)(4326008)(7696005)(86362001)(40480700001)(82740400003)(47076005)(40460700003)(70586007)(81166007)(110136005)(316002)(54906003)(70206006)(82310400005)(36756003)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2023 11:44:04.0812 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 916313e3-5299-4dd1-c0f8-08db005bca66 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: DBAEUR03FT005.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR08MB9925 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034421_804215_E5C4F699 X-CRM114-Status: UNSURE ( 8.25 ) X-CRM114-Notice: Please train this message. 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 Don't implicitly rely on this header being included. Signed-off-by: Joey Gouly Reviewed-by: Thomas Huth --- lib/string.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/string.h b/lib/string.h index b07763ea..758dca8a 100644 --- a/lib/string.h +++ b/lib/string.h @@ -7,6 +7,8 @@ #ifndef _STRING_H_ #define _STRING_H_ +#include /* For size_t */ + extern size_t strlen(const char *buf); extern size_t strnlen(const char *buf, size_t maxlen); extern char *strcat(char *dest, const char *src); From patchwork Fri Jan 27 11:40:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13118603 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 9CA5FC54EAA for ; Fri, 27 Jan 2023 12:21:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=N5PrZJp1CfpFuOw3wWtSzySSG4UD2+NtPK4Qi+sxhdA=; b=Cmi2rhcGQKrnz3 v8h85S1bnculKXbqgd3tMbeCnpZOYJ5rxd6AEO2C542FY6f6QfvuleUcQjcYqgQIYZh2qivFGtj5h L3j9eCpY9N1VNTkmDnmQk4mgKMqzkYRYTeZVlb05WvnLKFU9RfNtg9oFZ9/uOK1LdfcQzdVh+dUZ0 NOSz6XvlGhACkiD3c26yT8F5HwBRGdVpE29zupA0juWBnjgIjUbQFS/8MirJnWr1MIHSL02Lal2WU hIUM2T5joCoprTEQexsYF7QQ9ET2kda6hEg8y03KdL5IPKK5FGMZ3Hv4dhDFMs/nnjN1FfwOtOmjL ki59KBKRwCGIbsppckMw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNhm-00EV6k-Ob; Fri, 27 Jan 2023 12:19:44 +0000 Received: from mail-he1eur04on2089.outbound.protection.outlook.com ([40.107.7.89] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN7C-00EDhd-0t for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:41:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wMcwtlGekEAD65YfU8NXuKfzBIuUWm2fNmvX4BABa/I=; b=zUAwlXkO3HsOouGuiII0TbNTcNLGTfiYODHQnOU8XcnquggamJJ/R1xEIOurpHPhsSkHe2Mn+VN5j6xBYXA7jKkFC0lEB2qjo0Wgv0bRSTydaWesh+YrnMIMmzpbZTJgLsXtz/PXZd5GsxB273oLNs/Kw/TtaqaBmmCrmVsnkfY= Received: from AS9PR04CA0050.eurprd04.prod.outlook.com (2603:10a6:20b:46a::35) by GV2PR08MB8100.eurprd08.prod.outlook.com (2603:10a6:150:7a::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33; Fri, 27 Jan 2023 11:41:45 +0000 Received: from AM7EUR03FT017.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:46a:cafe::c8) by AS9PR04CA0050.outlook.office365.com (2603:10a6:20b:46a::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23 via Frontend Transport; Fri, 27 Jan 2023 11:41:45 +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 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM7EUR03FT017.mail.protection.outlook.com (100.127.140.184) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.22 via Frontend Transport; Fri, 27 Jan 2023 11:41:45 +0000 Received: ("Tessian outbound baf1b7a96f25:v132"); Fri, 27 Jan 2023 11:41:44 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: f541c80697b1d018 X-CR-MTA-TID: 64aa7808 Received: from ef6d3d9679ba.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 1235D9C1-D4EB-40A7-AF4E-4BCBA772B947.1; Fri, 27 Jan 2023 11:41:38 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id ef6d3d9679ba.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 27 Jan 2023 11:41:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DDS80Fatr69LDCB09zJP2pGgOkcxwRdgpS502m9mfHT6YINpkO8CCn4/damB6td1IspHUsVbrW24rzWeQzaP6MVMOXaLe1PybZNV66ac7jzlx9rMXzWIUMTbLFcsknLu+fPLmuL4qL7G8B6TgrGjFKX7/5EWeWv4i5Tdd7JBDLZ3OTcoo5nDlGYohtluqUAoY0eXMN6Kej8eMzLrK2cIbGS1/ljOATou4m5dzPbhFNYrtuebLtsHD+jr+Gc9loYrYWq/gnsAMGiIMLaSpp1tmaXta0uanEXGvU9RsCIBPpEgPf2IT2pgDJ2C+7+JbFHkJJ4PlinZK7spSIKKSwdYtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wMcwtlGekEAD65YfU8NXuKfzBIuUWm2fNmvX4BABa/I=; b=JOdnRuvCOzXu1OJNIDEk52DZrbXcXK3AWlpgtCeSzcDn8oLdZX6q8mfqqXB4By1JnwQmWFecDAtY9EhaJDFE4m5ss5beKAY4QHrbwN6p0t1l8R4KqSky4DwHarxIjZJiVeeR/wS1VwZNy7uj8pclXbSnfBQqERhdIs/l9n1WIoBExJhw3wQ5N/L6mcKZi9HFvo1/B8YxS4gWgQtSUq9Tvrikz6nPBYlBfE3wRnqvdkpC5JqbVFZwzuZ9cfenEgjp380539LZ8ssZChCg3XfLMD/B+RierTA2otOxG0pqVryd1AT+G3aTr76o3yOprWXlu5A7wVzyfqhnursxJe4L4Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=linux.dev smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wMcwtlGekEAD65YfU8NXuKfzBIuUWm2fNmvX4BABa/I=; b=zUAwlXkO3HsOouGuiII0TbNTcNLGTfiYODHQnOU8XcnquggamJJ/R1xEIOurpHPhsSkHe2Mn+VN5j6xBYXA7jKkFC0lEB2qjo0Wgv0bRSTydaWesh+YrnMIMmzpbZTJgLsXtz/PXZd5GsxB273oLNs/Kw/TtaqaBmmCrmVsnkfY= Received: from DUZPR01CA0164.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b3::18) by AS8PR08MB8706.eurprd08.prod.outlook.com (2603:10a6:20b:564::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23; Fri, 27 Jan 2023 11:41:35 +0000 Received: from DBAEUR03FT037.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:4b3:cafe::cb) by DUZPR01CA0164.outlook.office365.com (2603:10a6:10:4b3::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.35 via Frontend Transport; Fri, 27 Jan 2023 11:41:35 +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 Received: from nebula.arm.com (40.67.248.234) by DBAEUR03FT037.mail.protection.outlook.com (100.127.142.208) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6043.23 via Frontend Transport; Fri, 27 Jan 2023 11:41:34 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Fri, 27 Jan 2023 11:41:27 +0000 Received: from e124191.cambridge.arm.com (10.1.197.45) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Fri, 27 Jan 2023 11:41:21 +0000 From: Joey Gouly To: Andrew Jones , , CC: , Alexandru Elisei , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Suzuki K Poulose , "Thomas Huth" , Will Deacon , Zenghui Yu , , , , Subject: [RFC kvm-unit-tests 02/27] arm: Expand SMCCC arguments and return values Date: Fri, 27 Jan 2023 11:40:43 +0000 Message-ID: <20230127114108.10025-3-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230127114108.10025-1-joey.gouly@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127114108.10025-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT037:EE_|AS8PR08MB8706:EE_|AM7EUR03FT017:EE_|GV2PR08MB8100:EE_ X-MS-Office365-Filtering-Correlation-Id: cf508e93-a44c-4c0b-5d81-08db005b7798 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: oQJjb/Wo+WCK/3gYJfPP3Z6forKMnlJbI/FRPW/46kP030cHpBi22Kahjb4HzTWB0uQtsVm+X8imP/rkMU4db8+CsTHFd/ehkxorog2cpAWglvv/0Ic24SzIzB1O1DyCZkh1G6CXb4/7W2vQWK8FqJ8iM0SEYRP6YqIpdcLAsDk0bMnMLJ7nvWL1PeEzJTy37rE+GMsLmxyY+nvv803SJVyc46KyvLv0A7rQWnl+Bld/RySh9FJ/UFA4A85qcubj/eTdSc2ROvf6urPdmx4XtPUyQeDfa7+yNKkpQpvxJ/W5YpxU4Y5Y6HD8oujG0mneDfJUZsoFh9ECabmjCB+JaOPTNQFb5a7baiJWj3XYL0GOHnDoR3Uv2vimdRqXqbWZHRK5sg/M2Yz9XQx/nIWLNz+TxHd+Tiqk6rwzmXpuDbLve/jFJEAKLW/GW9umaMJ14loGlRKdAU293bqKqcyh3QOV29LhcEJGSMoiszmmjnLrv9G4GyrEvtm85K60Tbm+vVMiYqhwhR8+QfbnH7zcDd63Mf6fUzPAxYyU7hidxhceuNa7IIJJOPJZ3HnRW1SNfFJ6Capss9981jU33EK/I0LDgk48iFOcj+TWL1masK77ttOtQ8L1iOSmS9jKuzpgZ1ebgcVje8UnlvAzdGYdktiIEHMVSLEhekRfC91UC19JEpLLcWL4epU70SZ6A67rf6FikfIAHuPqkdgcvtjMXBqwC45r4Pbx74Gu6ZcXUk0rse1zHWEYSbR6yqEHYYif 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:(13230025)(4636009)(136003)(39860400002)(376002)(396003)(346002)(451199018)(40470700004)(36840700001)(46966006)(7696005)(336012)(478600001)(6666004)(2906002)(4326008)(26005)(186003)(44832011)(1076003)(8676002)(70206006)(70586007)(426003)(47076005)(110136005)(2616005)(54906003)(83380400001)(356005)(36860700001)(82740400003)(316002)(36756003)(5660300002)(41300700001)(40460700003)(7416002)(40480700001)(81166007)(8936002)(82310400005)(86362001)(36900700001)(2101003);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB8706 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT017.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: d055afe7-ace8-46c6-33e7-08db005b7115 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nrKyR4jNyayhEdziM22uajlH+oRk/9fdxhxFUnhWeOhpUutSB335Kkn6t0JlxWGyx5VoPAh6pWgHMpZccO5MNaeCEiLR7020oefheOTH0lJvWZaabDjW7XKEFqfajTjWEKRZqI9GYHWCRDczkkLeZRg55zB58wASQScWbIw2UxLQTvJszqJ4lFmrMu2EnAdhzh/h8FNRGKgPF6vMBTf8tWXWJEke79SDB5ePApeyXjdmuK8jeJlbijhwRoO6W9E2ODmgnMVvHHkaPR9imOjQkdBYDkvk/2XV82kmOUui4hq7dFHgn6L0Z74lhrcsyDodGZTEv1uOXBWMjDtli2tIj6ZEnKxeL+X80uxnxF67jmSN6pvN6d+rN4CReKtIGwJPWQHlHh52Wb4D5KveiNXxxOsblDUP1U5B98PzLUCgiiB7hnTFG6fN0YKqT5MAotYBi9FdAxoogaThFopCu10iYYDW4ZVziGgLGqdjvna2hwMgPab+rh07DMtVVG8vk6yMDaD7jm409PQ84fSa7Ytmc+xeAjMeFsUgkrKfZ6nyUXAhKtvAXHya8uHmprc0WaytYZN4HmQfeToYPh6j45jgcvIwo6DGosbhXJ1h3HI6J99WJP+14y0y0WZwdpbLR1B7pB31DWsc7nl+6HJvxjJZqL6hA3k1+yPUOjLyBI9W2VQ/mNb0E98nfgkGOczocJp1TTg68mY3I69f8BDRmt2uGheSN9xo0wLV9fXebdFkpiA= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230025)(4636009)(396003)(376002)(346002)(136003)(39860400002)(451199018)(40470700004)(46966006)(36840700001)(5660300002)(36860700001)(36756003)(82740400003)(83380400001)(1076003)(107886003)(26005)(7696005)(40480700001)(2616005)(47076005)(478600001)(316002)(6666004)(54906003)(110136005)(2906002)(44832011)(86362001)(8936002)(186003)(336012)(8676002)(81166007)(40460700003)(70206006)(70586007)(4326008)(82310400005)(41300700001)(426003)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2023 11:41:45.0774 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cf508e93-a44c-4c0b-5d81-08db005b7798 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: AM7EUR03FT017.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR08MB8100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034154_305804_86EDCC98 X-CRM114-Status: GOOD ( 14.87 ) 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 From: Alexandru Elisei PSCI uses the SMC Calling Convention (SMCCC) to communicate with the higher level software. PSCI uses at most 4 arguments and expend only one return value. However, SMCCC has provisions for more arguments (upto 17 depending on the SMCCC version) and upto 10 distinct return values. We are going to be adding tests that make use of it, so add support for the extended number of arguments and return values. Also rename the SMCCC functions to generic, non-PSCI names, so they can be used for Realm services. Signed-off-by: Alexandru Elisei [ Expand the number of args to 11 /results 10] Signed-off-by: Joey Gouly --- arm/cstart.S | 49 ++++++++++++++++++++++++++++------ arm/cstart64.S | 55 +++++++++++++++++++++++++++++++++------ arm/selftest.c | 2 +- lib/arm/asm/arm-smccc.h | 44 +++++++++++++++++++++++++++++++ lib/arm/asm/psci.h | 13 +++++---- lib/arm/psci.c | 19 +++++++++++--- lib/arm64/asm/arm-smccc.h | 6 +++++ 7 files changed, 160 insertions(+), 28 deletions(-) create mode 100644 lib/arm/asm/arm-smccc.h create mode 100644 lib/arm64/asm/arm-smccc.h diff --git a/arm/cstart.S b/arm/cstart.S index 7036e67f..db377668 100644 --- a/arm/cstart.S +++ b/arm/cstart.S @@ -96,26 +96,59 @@ start: .text /* - * psci_invoke_hvc / psci_invoke_smc + * arm_smccc_hvc / arm_smccc_smc * * Inputs: * r0 -- function_id * r1 -- arg0 * r2 -- arg1 * r3 -- arg2 + * [sp] - arg3 + * [sp + #4] - arg4 + * [sp + #8] - arg5 + * [sp + #12] - arg6 + * [sp + #16] - arg7 + * [sp + #20] - arg8 + * [sp + #24] - arg9 + * [sp + #28] - arg10 + * [sp + #32] - result (as a pointer to a struct smccc_result) * * Outputs: * r0 -- return code + * + * If result pointer is not NULL: + * result.r0 -- return code + * result.r1 -- r1 + * result.r2 -- r2 + * result.r3 -- r3 + * result.r4 -- r4 + * result.r5 -- r5 + * result.r6 -- r6 + * result.r7 -- r7 + * result.r8 -- r8 + * result.r9 -- r9 */ -.globl psci_invoke_hvc -psci_invoke_hvc: - hvc #0 +.macro do_smccc_call instr + mov r12, sp + push {r4-r11} + ldm r12, {r4-r11} + \instr #0 + ldr r10, [sp, #64] + cmp r10, #0 + beq 1f + stm r10, {r0-r9} +1: + pop {r4-r11} mov pc, lr +.endm -.globl psci_invoke_smc -psci_invoke_smc: - smc #0 - mov pc, lr +.globl arm_smccc_hvc +arm_smccc_hvc: + do_smccc_call hvc + +.globl arm_smccc_smc +arm_smccc_smc: + do_smccc_call smc enable_vfp: /* Enable full access to CP10 and CP11: */ diff --git a/arm/cstart64.S b/arm/cstart64.S index e4ab7d06..b689b132 100644 --- a/arm/cstart64.S +++ b/arm/cstart64.S @@ -110,26 +110,65 @@ start: .text /* - * psci_invoke_hvc / psci_invoke_smc + * arm_smccc_hvc / arm_smccc_smc * * Inputs: * w0 -- function_id * x1 -- arg0 * x2 -- arg1 * x3 -- arg2 + * x4 -- arg3 + * x5 -- arg4 + * x6 -- arg5 + * x7 -- arg6 + * sp -- { arg7, arg8, arg9, arg10, result } * * Outputs: * x0 -- return code + * + * If result pointer is not NULL: + * result.r0 -- return code + * result.r1 -- x1 + * result.r2 -- x2 + * result.r3 -- x3 + * result.r4 -- x4 + * result.r5 -- x5 + * result.r6 -- x6 + * result.r7 -- x7 + * result.r8 -- x8 + * result.r9 -- x9 */ -.globl psci_invoke_hvc -psci_invoke_hvc: - hvc #0 +.macro do_smccc_call instr + /* Save x8-x11 on stack */ + stp x9, x8, [sp, #-16]! + stp x11, x10, [sp, #-16]! + /* Load arg7 - arg10 from the stack */ + ldp x8, x9, [sp, #32] + ldp x10, x11, [sp, #48] + \instr #0 + /* Get the result address */ + ldr x10, [sp, #64] + cmp x10, xzr + b.eq 1f + stp x0, x1, [x10, #0] + stp x2, x3, [x10, #16] + stp x4, x5, [x10, #32] + stp x6, x7, [x10, #48] + stp x8, x9, [x10, #64] +1: + /* Restore x8-x11 from stack */ + ldp x11, x10, [sp], #16 + ldp x9, x8, [sp], #16 ret +.endm -.globl psci_invoke_smc -psci_invoke_smc: - smc #0 - ret +.globl arm_smccc_hvc +arm_smccc_hvc: + do_smccc_call hvc + +.globl arm_smccc_smc +arm_smccc_smc: + do_smccc_call smc get_mmu_off: adrp x0, auxinfo diff --git a/arm/selftest.c b/arm/selftest.c index 9f459ed3..6f825add 100644 --- a/arm/selftest.c +++ b/arm/selftest.c @@ -405,7 +405,7 @@ static void psci_print(void) int ver = psci_invoke(PSCI_0_2_FN_PSCI_VERSION, 0, 0, 0); report_info("PSCI version: %d.%d", PSCI_VERSION_MAJOR(ver), PSCI_VERSION_MINOR(ver)); - report_info("PSCI method: %s", psci_invoke == psci_invoke_hvc ? + report_info("PSCI method: %s", psci_invoke_fn == arm_smccc_hvc ? "hvc" : "smc"); } diff --git a/lib/arm/asm/arm-smccc.h b/lib/arm/asm/arm-smccc.h new file mode 100644 index 00000000..5d85b01a --- /dev/null +++ b/lib/arm/asm/arm-smccc.h @@ -0,0 +1,44 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2022 Arm Limited. + * All rights reserved. + */ +#ifndef _ASMARM_ARM_SMCCC_H_ +#define _ASMARM_ARM_SMCCC_H_ + +struct smccc_result { + unsigned long r0; + unsigned long r1; + unsigned long r2; + unsigned long r3; + unsigned long r4; + unsigned long r5; + unsigned long r6; + unsigned long r7; + unsigned long r8; + unsigned long r9; +}; + +typedef int (*smccc_invoke_fn)(unsigned int function_id, unsigned long arg0, + unsigned long arg1, unsigned long arg2, + unsigned long arg3, unsigned long arg4, + unsigned long arg5, unsigned long arg6, + unsigned long arg7, unsigned long arg8, + unsigned long arg9, unsigned long arg10, + struct smccc_result *result); +extern int arm_smccc_hvc(unsigned int function_id, unsigned long arg0, + unsigned long arg1, unsigned long arg2, + unsigned long arg3, unsigned long arg4, + unsigned long arg5, unsigned long arg6, + unsigned long arg7, unsigned long arg8, + unsigned long arg9, unsigned long arg10, + struct smccc_result *result); +extern int arm_smccc_smc(unsigned int function_id, unsigned long arg0, + unsigned long arg1, unsigned long arg2, + unsigned long arg3, unsigned long arg4, + unsigned long arg5, unsigned long arg6, + unsigned long arg7, unsigned long arg8, + unsigned long arg9, unsigned long arg10, + struct smccc_result *result); + +#endif /* _ASMARM_ARM_SMCCC_H_ */ diff --git a/lib/arm/asm/psci.h b/lib/arm/asm/psci.h index cf03449b..6a399621 100644 --- a/lib/arm/asm/psci.h +++ b/lib/arm/asm/psci.h @@ -3,13 +3,12 @@ #include #include -typedef int (*psci_invoke_fn)(unsigned int function_id, unsigned long arg0, - unsigned long arg1, unsigned long arg2); -extern psci_invoke_fn psci_invoke; -extern int psci_invoke_hvc(unsigned int function_id, unsigned long arg0, - unsigned long arg1, unsigned long arg2); -extern int psci_invoke_smc(unsigned int function_id, unsigned long arg0, - unsigned long arg1, unsigned long arg2); +#include + +extern smccc_invoke_fn psci_invoke_fn; + +extern int psci_invoke(unsigned int function_id, unsigned long arg0, + unsigned long arg1, unsigned long arg2); extern void psci_set_conduit(void); extern int psci_cpu_on(unsigned long cpuid, unsigned long entry_point); extern void psci_system_reset(void); diff --git a/lib/arm/psci.c b/lib/arm/psci.c index 9c031a12..0a1d0e82 100644 --- a/lib/arm/psci.c +++ b/lib/arm/psci.c @@ -13,13 +13,24 @@ #include static int psci_invoke_none(unsigned int function_id, unsigned long arg0, - unsigned long arg1, unsigned long arg2) + unsigned long arg1, unsigned long arg2, + unsigned long arg3, unsigned long arg4, + unsigned long arg5, unsigned long arg6, + unsigned long arg7, unsigned long arg8, + unsigned long arg9, unsigned long arg10, + struct smccc_result *result) { printf("No PSCI method configured! Can't invoke...\n"); return PSCI_RET_NOT_PRESENT; } -psci_invoke_fn psci_invoke = psci_invoke_none; +smccc_invoke_fn psci_invoke_fn = psci_invoke_none; + +int psci_invoke(unsigned int function_id, unsigned long arg0, + unsigned long arg1, unsigned long arg2) +{ + return psci_invoke_fn(function_id, arg0, arg1, arg2, 0, 0, 0, 0, 0, 0, 0, 0, NULL); +} int psci_cpu_on(unsigned long cpuid, unsigned long entry_point) { @@ -69,9 +80,9 @@ void psci_set_conduit(void) assert(method != NULL && len == 4); if (strcmp(method->data, "hvc") == 0) - psci_invoke = psci_invoke_hvc; + psci_invoke_fn = arm_smccc_hvc; else if (strcmp(method->data, "smc") == 0) - psci_invoke = psci_invoke_smc; + psci_invoke_fn = arm_smccc_smc; else assert_msg(false, "Unknown PSCI conduit: %s", method->data); } diff --git a/lib/arm64/asm/arm-smccc.h b/lib/arm64/asm/arm-smccc.h new file mode 100644 index 00000000..ab649489 --- /dev/null +++ b/lib/arm64/asm/arm-smccc.h @@ -0,0 +1,6 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2022 Arm Limited. + * All rights reserved. + */ +#include "../../arm/asm/arm-smccc.h" From patchwork Fri Jan 27 11:40:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13118656 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 B38E4C54EAA for ; Fri, 27 Jan 2023 13:00:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=QWkVAIFQ+iV5Ks/aWa6G/06YcAX0QvCmzg3Ic3J7Bcs=; b=jsIqKXQ9uLijhZ Iq4d6WKk4W3PppwWnwgDM999xtPQLkJLcnyQBZsdKdWpZkg7dbDV4XxkT64P+vDAOlW0BUhe6M7zx WpLKEiqsZ1ed8rTtqdVtq2udsDqTs51hySzCqHBHMaqEQ4rSpMbfIOuaYjWXLJEcESdfoQuiYy4HG pS5djJ6eSHZEGhN6OHDwatRBe26qo89nvpskbgM5pPySYH4L8a81DIURv5HfrUPm+Q/bWolZt6nNN VmHxjzKCkkzAiLsGNbXituwX1rPbz3YGBoGYghi69B4MtXyPr6rtf3dC3SYMeacCgvZz+vK3zvuz/ 15Pzp0JlXMm09h9wqShA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLOIJ-00Em5W-Md; Fri, 27 Jan 2023 12:57:33 +0000 Received: from mail-ve1eur01on2051.outbound.protection.outlook.com ([40.107.14.51] helo=EUR01-VE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNMQ-00EKj1-CT for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:57:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mfmG/SscmSCGgdmMDRai/tE1Awu1KRQPqX/oIQCKwoM=; b=+JqUBo/jsRhua9s3PCNyd9sDD1dh2ja9Z4UAwuyOhQT2SIck9DFVGzkhC/3MNT5RZyGEgFD/n2xveKp/HfsxLVXFM6+uJgPh5LEtrZPpHJt/X5tN5uYi01rt1V/DX4TsJn809sSe2cSPC3VQkEkqQc9APcVMF1Gowb45DSlNjWA= Received: from AM6P191CA0074.EURP191.PROD.OUTLOOK.COM (2603:10a6:209:8a::15) by GV2PR08MB9255.eurprd08.prod.outlook.com (2603:10a6:150:e3::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.22; Fri, 27 Jan 2023 11:41:45 +0000 Received: from AM7EUR03FT047.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:8a:cafe::de) by AM6P191CA0074.outlook.office365.com (2603:10a6:209:8a::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23 via Frontend Transport; Fri, 27 Jan 2023 11:41:45 +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 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM7EUR03FT047.mail.protection.outlook.com (100.127.140.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23 via Frontend Transport; Fri, 27 Jan 2023 11:41:44 +0000 Received: ("Tessian outbound 0d7b2ab0f13d:v132"); Fri, 27 Jan 2023 11:41:44 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 01b30c8a8973a124 X-CR-MTA-TID: 64aa7808 Received: from 414c00eca92b.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 2C600D57-46FD-4933-9EA1-500F83CBE8BA.1; Fri, 27 Jan 2023 11:41:38 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 414c00eca92b.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 27 Jan 2023 11:41:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TzosGICsOKX23lXJIKzEiVxLH5VYcjXf+BDei8VgB9tLNgdfs7T4M62DnARQ3lTnaSuJwTQn13ohiJ5V50ipTcbIF4J8BepBHx8yd1/hBTL110uHt+6lZoZRFuZUO687xHPMOCuoI+hu9NLkO57f6gegPpmaVsepjLhzZvKu/ehtTcE5CsVF/j1CsJYwO4E2Usg2X+5Ck9ZFLX3x38JhvsWPsbLYxZO4O51etbNYcQZ+bh/ns00av++eZkIPrMLCC20baIti4zyNaZqqSyiHKv5K0W0uCYo9O/DGi5KiqJnPn0pyyd7vO90k8l7DUQsJBOzf+ajIlxXwiKg6bbwFCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mfmG/SscmSCGgdmMDRai/tE1Awu1KRQPqX/oIQCKwoM=; b=Q6xI2j/TbAR+DvXnakWyFxmv6cBI+KQ5UBYpK6/64AfUPDbvyiVKn/yrX08zRX/ptSiOgFb/qJP0RZOrjqfAAL1laLL0DGYj/FuHRKKPMQN1c+qxLI5qQRlYa3Mcjg7FF3qiPBaVe0euLhnNg8+9IS3qLo/EQlLwY4P8jEh0gXOGhZw9rzNKE70MwsO//GE9l5/En4DZxyAHrkFTBzmJzw8aIxUsoeQWsDrOHW00foE9hzBMNDgkKW57yEyIck6DZbvN0/dOjw8ZiDW3h6eDR4TmwM+VKiT4gbrlBhyj4QzvUZdfwR9QRQmeIbZixPhg4+70juGfRDOquVMmKPmbzA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=linux.dev smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mfmG/SscmSCGgdmMDRai/tE1Awu1KRQPqX/oIQCKwoM=; b=+JqUBo/jsRhua9s3PCNyd9sDD1dh2ja9Z4UAwuyOhQT2SIck9DFVGzkhC/3MNT5RZyGEgFD/n2xveKp/HfsxLVXFM6+uJgPh5LEtrZPpHJt/X5tN5uYi01rt1V/DX4TsJn809sSe2cSPC3VQkEkqQc9APcVMF1Gowb45DSlNjWA= Received: from AM5PR0101CA0004.eurprd01.prod.exchangelabs.com (2603:10a6:206:16::17) by DU0PR08MB7637.eurprd08.prod.outlook.com (2603:10a6:10:31c::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.28; Fri, 27 Jan 2023 11:41:34 +0000 Received: from AM7EUR03FT061.eop-EUR03.prod.protection.outlook.com (2603:10a6:206:16:cafe::55) by AM5PR0101CA0004.outlook.office365.com (2603:10a6:206:16::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.34 via Frontend Transport; Fri, 27 Jan 2023 11:41:33 +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 Received: from nebula.arm.com (40.67.248.234) by AM7EUR03FT061.mail.protection.outlook.com (100.127.140.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6043.23 via Frontend Transport; Fri, 27 Jan 2023 11:41:33 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) 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.16; Fri, 27 Jan 2023 11:41:32 +0000 Received: from e124191.cambridge.arm.com (10.1.197.45) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Fri, 27 Jan 2023 11:41:27 +0000 From: Joey Gouly To: Andrew Jones , , CC: , Alexandru Elisei , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Suzuki K Poulose , "Thomas Huth" , Will Deacon , Zenghui Yu , , , , Subject: [RFC kvm-unit-tests 03/27] arm: realm: Add RSI interface header Date: Fri, 27 Jan 2023 11:40:44 +0000 Message-ID: <20230127114108.10025-4-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230127114108.10025-1-joey.gouly@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127114108.10025-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT061:EE_|DU0PR08MB7637:EE_|AM7EUR03FT047:EE_|GV2PR08MB9255:EE_ X-MS-Office365-Filtering-Correlation-Id: 627a22a5-3c51-4d10-637a-08db005b7784 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: BVjsYobxHabxc5fQduZYXdoGRTBp3BtDg2neAkTMmuIleelJgyk/pxf4dD6HOmq13+BqmX1UHjDVNDSgeSjM0YdUSmpsAOGyOkx1V/VdgUXh5rZe5S7QkdDaBTBKz4SFwHfjK44Yu3D09nd7bIJ7BRryJfJgWypWaUrGpM+jgvr0Sc4Q9FLIRSA/xoxRIEiR0HO/J8dUUAaZY1zx0Cv8trl8hQIMBEUbDwA9IJaD6WRXnqk2ufFmoki493X7/s4t0cIus6V8cdYCxPjkPByTzDXFE1+zSSIGzT4DfgEpH6bwFjtECAMUo2shhVVamNnQJ0xfNRNyxccbkdnxhsMOhobCJtwXDMMzUf4yAertjJeym07VT+MdPz69jAI3PimRANNor6j1qQzlZPnz0cQck7Jlnvj12K/n8+PE1yhaFyqP36LD3E2dB8zbv0A8qe1buOrvmrCY5w6Tjwdy/u6/63qR/maNlLDlDAuQtjoghM3RjzCpCYH/yfNdJpXZi7fppbxBXZykVc6PmqJhOK4vdMLTz16+w7F3R0uJdasdbs0ADjE0tmoG0/3MCg/T7mT2g+q8KSJKm4QaXf6k7bQyy70tHjODHMm+Bh89eLbmRZJ22/6BnE6Fdwrkp/ztfVpTmPbBm51dLhw7IE8SATvHMSwZ7Fu8ouVoR0J0ddXgoKXVulwh7cMHeS9EXxjn6femrS5CNkw0VQPhQQOF+SJTFIUYTRb7IKUzbSLxcqdVR1HRKa5eF5RxNwpVm3b7fdG/ 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:(13230025)(4636009)(396003)(376002)(39860400002)(346002)(136003)(451199018)(46966006)(36840700001)(40470700004)(36756003)(336012)(70206006)(41300700001)(478600001)(70586007)(82310400005)(4326008)(26005)(2616005)(316002)(1076003)(7696005)(81166007)(426003)(7416002)(54906003)(83380400001)(356005)(6666004)(5660300002)(40460700003)(110136005)(8676002)(40480700001)(82740400003)(44832011)(36860700001)(86362001)(186003)(47076005)(8936002)(2906002)(2101003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB7637 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT047.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 51920a98-4f0b-4763-9801-08db005b70de X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: F4TFk5nHLjLKM8DUDX0p5QSO3RrPHlA+DF7uX/JSUSegZGH0Rh5OCofKmd8MbAa7zocW93QSyz9TfoWx0gZJK8DPy7ReTEq9qT4sYuPRpXogcxxVcZ1js9vqQcGIYbNN/YTPpkERN/v2UDxVFzJbrEAPjXVOCYFlhuImz42awf6mIWuYSu/DUrOS8Q89NvaxjgzrJ8FTMjLj4XeRHytiHkspQyWIWqxzd/VGWVAhsOoYR+1LSwXMqn4KYqgXByrQ+qcoJHg/v4RC65DSunfyyFs7An91CMuE2pH81hfq/E7L5EkUJ00LjS5PWktPlZuXbNqCrGwMsm5kHGVlNU+YmM2PAIXonszAWNDT2CTRNdEqn7JpdU3VTW9GlXX1cfuTwU7v1AgZ++fmz/v+aTRhrHZiU1odEhmlQQGmavj+i1T/fprCckw90TNAVVfOvwWCTUYaJNvYJdB1/AveBtRHdI7FxITf3ce/9bccxG/hDjV+JeqlpdXGgHwpq+VVrtrhcKZB06DtJrgUXRyTcqOf3pvAJZMgo9eRXgGqMH0wJLW90Kcvw6q3kZvsxknqA257MAm+TvsEpOClsogXJnlYpLh6MiuRa6IQGeIPwMgHckBgHH/saFwlP/+O/OBocoGcc1jposyHZqPLJqSu0V1JHzTIRh0ngo6PCC8P80CNuLwI56vzSkjeNxdaZWAt7l98OmHPtN1hw4s3+SvKY/vEXMjFx04Jsxk7kQhwUjrlhD8= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230025)(4636009)(136003)(396003)(376002)(346002)(39860400002)(451199018)(40470700004)(36840700001)(46966006)(82310400005)(36860700001)(1076003)(2616005)(8936002)(81166007)(40460700003)(2906002)(44832011)(110136005)(54906003)(82740400003)(316002)(7696005)(41300700001)(478600001)(426003)(86362001)(40480700001)(83380400001)(186003)(26005)(6666004)(107886003)(70586007)(70206006)(47076005)(8676002)(36756003)(5660300002)(336012)(4326008)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2023 11:41:44.9777 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 627a22a5-3c51-4d10-637a-08db005b7784 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: AM7EUR03FT047.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR08MB9255 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_035738_638312_DE4393B3 X-CRM114-Status: GOOD ( 18.04 ) 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 Add the defintions for the Realm Service Interface (RSI). RSI calls are a way for the Realm to communicate with the RMM and request information/services. Signed-off-by: Joey Gouly --- lib/arm64/asm/smc-rsi.h | 139 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 lib/arm64/asm/smc-rsi.h diff --git a/lib/arm64/asm/smc-rsi.h b/lib/arm64/asm/smc-rsi.h new file mode 100644 index 00000000..cd05e9c6 --- /dev/null +++ b/lib/arm64/asm/smc-rsi.h @@ -0,0 +1,139 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2022 Arm Limited. + * All rights reserved. + */ +#ifndef __SMC_RSI_H_ +#define __SMC_RSI_H_ + +/* + * This file describes the Realm Services Interface (RSI) Application Binary + * Interface (ABI) for SMC calls made from within the Realm to the RMM and + * serviced by the RMM. + */ + +#define SMC_RSI_CALL_BASE 0xC4000000 + +/* + * The major version number of the RSI implementation. Increase this whenever + * the binary format or semantics of the SMC calls change. + */ +#define RSI_ABI_VERSION_MAJOR 12 + +/* + * The minor version number of the RSI implementation. Increase this when + * a bug is fixed, or a feature is added without breaking binary compatibility. + */ +#define RSI_ABI_VERSION_MINOR 0 + +#define RSI_ABI_VERSION ((RSI_ABI_VERSION_MAJOR << 16) | \ + RSI_ABI_VERSION_MINOR) + +#define RSI_ABI_VERSION_GET_MAJOR(_version) ((_version) >> 16) +#define RSI_ABI_VERSION_GET_MINOR(_version) ((_version) & 0xFFFF) + +#define RSI_SUCCESS 0 +#define RSI_ERROR_INPUT 1 +#define RSI_ERROR_STATE 2 +#define RSI_INCOMPLETE 3 +#define RSI_ERROR_MEMORY 4 + +#define SMC_RSI_FID(_x) (SMC_RSI_CALL_BASE + (_x)) + +#define SMC_RSI_ABI_VERSION SMC_RSI_FID(0x190) + +/* + * arg1 == The IPA of token buffer + * arg2 == Challenge value, bytes: 0 - 7 + * arg3 == Challenge value, bytes: 7 - 15 + * arg4 == Challenge value, bytes: 16 - 23 + * arg5 == Challenge value, bytes: 24 - 31 + * arg6 == Challenge value, bytes: 32 - 39 + * arg7 == Challenge value, bytes: 40 - 47 + * arg8 == Challenge value, bytes: 48 - 55 + * arg9 == Challenge value, bytes: 56 - 63 + * ret0 == Status / error + */ +#define SMC_RSI_ATTEST_TOKEN_INIT SMC_RSI_FID(0x194) + +/* + * arg1 == The IPA of token buffer + * ret0 == Status / error + * ret1 == Size of completed token in bytes + */ +#define SMC_RSI_ATTEST_TOKEN_CONTINUE SMC_RSI_FID(0x195) + +/* + * arg1 == Index (1..4), which measurement (REM) to extend + * arg2 == Size of realm measurement in bytes, max 64 bytes + * arg3 == Measurement value, bytes: 0 - 7 + * arg4 == Measurement value, bytes: 7 - 15 + * arg5 == Measurement value, bytes: 16 - 23 + * arg6 == Measurement value, bytes: 24 - 31 + * arg7 == Measurement value, bytes: 32 - 39 + * arg8 == Measurement value, bytes: 40 - 47 + * arg9 == Measurement value, bytes: 48 - 55 + * arg10 == Measurement value, bytes: 56 - 63 + * ret0 == Status / error + */ +#define SMC_RSI_MEASUREMENT_EXTEND SMC_RSI_FID(0x193) + +/* + * arg1 == Index (0..4), which measurement (RIM or REM) to read + * ret0 == Status / error + * ret1 == Measurement value, bytes: 0 - 7 + * ret2 == Measurement value, bytes: 7 - 15 + * ret3 == Measurement value, bytes: 16 - 23 + * ret4 == Measurement value, bytes: 24 - 31 + * ret5 == Measurement value, bytes: 32 - 39 + * ret6 == Measurement value, bytes: 40 - 47 + * ret7 == Measurement value, bytes: 48 - 55 + * ret8 == Measurement value, bytes: 56 - 63 + */ +#define SMC_RSI_MEASUREMENT_READ SMC_RSI_FID(0x192) + +#ifndef __ASSEMBLY__ + +struct rsi_realm_config { + union { + struct { + unsigned long ipa_width; /* Width of IPA in bits */ + }; + unsigned char __reserved0[0x1000]; + }; + /* Offset 0x1000 */ +}; + +#endif /* __ASSEMBLY__ */ + +/* + * arg0 == struct rsi_realm_config addr + */ +#define SMC_RSI_REALM_CONFIG SMC_RSI_FID(0x196) + +/* + * arg0 == IPA address of target region + * arg1 == size of target region in bytes + * arg2 == RIPAS value + * ret0 == Status / error + * ret1 == Top of modified IPA range + */ +#define SMC_RSI_IPA_STATE_SET SMC_RSI_FID(0x197) + +#define RSI_HOST_CALL_NR_GPRS 31 + +#ifndef __ASSEMBLY__ + +struct rsi_host_call { + unsigned int imm; + unsigned long gprs[RSI_HOST_CALL_NR_GPRS]; +}; + +#endif /* __ASSEMBLY__ */ + +/* + * arg0 == struct rsi_host_call addr + */ +#define SMC_RSI_HOST_CALL SMC_RSI_FID(0x199) + +#endif /* __SMC_RSI_H_ */ From patchwork Fri Jan 27 11:40:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13118655 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 47461C38142 for ; Fri, 27 Jan 2023 12:57:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=aW1HbEPjCm5U7wQxRiAs7D3DaRawzHuVJ2+ZOpwm8yM=; b=B47Vn2NR/4CyjH Vn2nncaa8EWf9/UanIZgb4cjw+pd6CRRtUy2SQAjMXmvFz0IU3RieOTaScCYlVddaaMpHutRB3dze kgLfwoWfaO2q/sKpfbQw6ggwYEOnkDDofhnwCVHpGok68Eg9lwCuS6isTDpipipFNEIuSmE2kYfwj GqkGHGlWjcnnz50AbBpOYD3vmWjao2kc57qCpRllelPmfXcGI4rXQkucoNAQVMl8d1nfZqoIo0VgJ QrIsEnAJ2Ig1OPi+YFXh9imC9aDQnh/AfKa5ULnwAzQy76Vgi+w+ojZJNenoujNlFQHzdNTr2Da4M RRu40QimKF1kmdMQw1kg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLOGj-00Ekxt-IU; Fri, 27 Jan 2023 12:55:54 +0000 Received: from mail-vi1eur05on2067.outbound.protection.outlook.com ([40.107.21.67] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNMN-00EKhQ-HU for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:57:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=H8sHXFvJ6444qJbO+o+cXMiU4CBVfbUwsWai7SxWeag=; b=e2/XbBfwNMmUC+Gvs3Wymu04s11GLUMlFwKiOOj+FVgYOrxAOc4oPahAtcQZyXyrwz66h1VM19w5PB4IY5GR9hcUKwiNVjneldF+I/quaF+Wvp0e+A8frRNpELBIeKkfFX/tkyKuSjn27NrZfV/vMoIZ0ucA4Q3gdAfbbP858rw= Received: from DU2PR04CA0199.eurprd04.prod.outlook.com (2603:10a6:10:28d::24) by DU2PR08MB10085.eurprd08.prod.outlook.com (2603:10a6:10:496::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33; Fri, 27 Jan 2023 11:41:49 +0000 Received: from DBAEUR03FT010.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:28d:cafe::4c) by DU2PR04CA0199.outlook.office365.com (2603:10a6:10:28d::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23 via Frontend Transport; Fri, 27 Jan 2023 11:41:49 +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 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT010.mail.protection.outlook.com (100.127.142.78) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.21 via Frontend Transport; Fri, 27 Jan 2023 11:41:49 +0000 Received: ("Tessian outbound b1d3ffe56e73:v132"); Fri, 27 Jan 2023 11:41:49 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 5a31f9a9640e9a99 X-CR-MTA-TID: 64aa7808 Received: from e0b838b7eec7.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id D13009A3-622D-449A-8551-F371553DB98C.1; Fri, 27 Jan 2023 11:41:43 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id e0b838b7eec7.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 27 Jan 2023 11:41:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OjvLzw4zXix/ilBq/8OWJaaTOJO7yDqbyWC0mE9TbIh4A9sapAQ3gTbGKjPOn8ZrhuWZjRR7+rj5SjDCUa1Ij+MMNWCZS77KnY6kgAGGqbitqrAW3JCpubkMIwRrtrHFlPbtd7IReb3v0C6OaZ0h3enY0QM8M0Xi0/uOruFE9vhdw1aWoxUbSCty4H6BZn+U05hH2qmJjz0YS6BW4yxO2CsLFExWgDjElx73a+7v3S8nWnCaMSGOZlYDj1WBtQNpkiGDE1hktqQOuaBweRhfGkxl78cd5vnj0uq+FLCmkWTDhSYPSWolxumZq393Uvt51Fh1Z3Hq4mIfg8WPfka9qQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=H8sHXFvJ6444qJbO+o+cXMiU4CBVfbUwsWai7SxWeag=; b=SCIM5fz38RRTNTo6ZMTieMSqAFm2fBqQCKoNo9JtpGcV3T7k3YtWfMYr+mkoA9IOI5A3aqMGbuRnGLjtThpAlTnR/WIM2vGV41xow7TpPFQFVKqpueP1HOWG7NrquAAjaM1nL4k5kMog7njTfSYc+8WzburuLKXOKWOi7iBJNR7ITHfkdiSCD/Op41C85B714C6yMvZ2LUWtjGxzM13d7r0jyY5oLPxkqV+vKlodlRkoE9pKTlj3eh66n/NMhSergh5jZfPebBxJMjBupXTjcFounTomCu5bd355F9gQJ1Gvp4PIij6q4lkJ3TVMT9T/i36Nu4/VP1muoUoU63gRDg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=linux.dev smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=H8sHXFvJ6444qJbO+o+cXMiU4CBVfbUwsWai7SxWeag=; b=e2/XbBfwNMmUC+Gvs3Wymu04s11GLUMlFwKiOOj+FVgYOrxAOc4oPahAtcQZyXyrwz66h1VM19w5PB4IY5GR9hcUKwiNVjneldF+I/quaF+Wvp0e+A8frRNpELBIeKkfFX/tkyKuSjn27NrZfV/vMoIZ0ucA4Q3gdAfbbP858rw= Received: from AS8P251CA0019.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:2f2::22) by PAWPR08MB10240.eurprd08.prod.outlook.com (2603:10a6:102:366::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33; Fri, 27 Jan 2023 11:41:40 +0000 Received: from AM7EUR03FT040.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:2f2:cafe::fa) by AS8P251CA0019.outlook.office365.com (2603:10a6:20b:2f2::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23 via Frontend Transport; Fri, 27 Jan 2023 11:41:39 +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 Received: from nebula.arm.com (40.67.248.234) by AM7EUR03FT040.mail.protection.outlook.com (100.127.140.128) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6043.21 via Frontend Transport; Fri, 27 Jan 2023 11:41:39 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) 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.16; Fri, 27 Jan 2023 11:41:38 +0000 Received: from e124191.cambridge.arm.com (10.1.197.45) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Fri, 27 Jan 2023 11:41:33 +0000 From: Joey Gouly To: Andrew Jones , , CC: , Alexandru Elisei , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Suzuki K Poulose , "Thomas Huth" , Will Deacon , Zenghui Yu , , , , Subject: [RFC kvm-unit-tests 04/27] arm: Make physical address mask dynamic Date: Fri, 27 Jan 2023 11:40:45 +0000 Message-ID: <20230127114108.10025-5-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230127114108.10025-1-joey.gouly@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127114108.10025-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT040:EE_|PAWPR08MB10240:EE_|DBAEUR03FT010:EE_|DU2PR08MB10085:EE_ X-MS-Office365-Filtering-Correlation-Id: 9d44be54-1a94-4b10-f50d-08db005b7a6b 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: NcAY6Ey9UNYkbzeWzIE9gX9s1ZThcug6XtKJ7XfSFzseZChi/OGbtRq2tFle65O1/3evqnnN43m3cX+2h5aXjdpZSZ1IOdOYRmqAYrgQbBCgUXc5wjbm8Dhlng2+NQQseedy5aozC/hWE+QD70AC4nVM3/FGsr8TUPfR+UWeZTMCcHPYgVIQ5vrW/+DAJupUNXnmpJN/+6TlRIGU7hHxf//ymKeOOBeVPDjZxO0RCuUou0FFMOFprMnlTJQGBLgQHHaP69JBFcDNvdEpSHEyj+grkGCN8iLLyN8XEmrwJBV2X51Y43Vk1iIkGtO0Jcgu9pu/o6c7q5zlst1Jr27W3iBTUYW1qayLOSOi3m4hvcGaEpSxqbNXLN8ErgzNSMd4ao7u96Gmp1oJUHuW4rzy3pjdEqa+0Z4ae6s5SJv2UMEYKhPgNyrK1lRIpE5UCFVEdpEi30wdKVx+MJXshf7CndXyNfcmRDrwfIgK4OClzVK2QgZG1LYvVR6y0cu/Qip8l7gyuzZL1Ru4SFBRlp9gQwy9mY/qIN4pcsyQ0Yt9l41pfOaUks9N3BwP5iVJcAxaBQDGhkyCqXa10InpzKOy7eV90SgZzUByezuEToJdkScG/GFczUMM8cPMb0rnTI3orNBzYoAdZcZVGlADO363bOoRL2zNLQ95m3SFnrvFZxX2bvQ8qOcoAHiA9TOQRIehTkh1Sz9uKvbjc9tYmXLXG2qbQIuEIrMRKWXF7t9Bxz0uFL7y4GPc6xbO27RA47gO 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:(13230025)(4636009)(396003)(39860400002)(136003)(376002)(346002)(451199018)(36840700001)(46966006)(40470700004)(336012)(82740400003)(110136005)(426003)(26005)(8936002)(478600001)(7696005)(86362001)(41300700001)(356005)(7416002)(36756003)(2616005)(40480700001)(81166007)(82310400005)(44832011)(4326008)(40460700003)(1076003)(186003)(54906003)(70206006)(5660300002)(316002)(8676002)(6666004)(47076005)(2906002)(70586007)(83380400001)(36860700001)(36900700001)(2101003);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR08MB10240 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT010.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: c5e6b6b8-f472-4473-700f-08db005b742d X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5Xdm+4W2Bsf5b3JvXRM8HE4yfC/LJyLLIGrz0PSdvUl355oV4P84j3GxD6OsuMBhPfdqUNQdcEGyyQDenze3boTC8xYkzn9R/+Z/7y7X2esxLw0WAahtA3yuwNKMdIW4rikxlfziJMsFPq+daXQ9JeK266oNmZH7jZetSYQiEKWEO0e+xxL5lMknIBqnKX4tcr6UhuD6dE0bLIkj7THgjRomO9rMKy9IrSz+p1UOASXB6nCw3o7y1FZFePmh2VC8cwPpgDFn6115BPJncuLYtKnTSmxWkqoD1qix1Zgwu4e2tDgUv4apTcZhPBBiTCuEcT6cZJZphqTwypouiU7ppB0tW3J5+nlB/CltYQmtCmWCgbwDj1tBrW87i0DUQ4kGlAbCEmyqc/gsKqxSLzajO1errKVvSPqNmiczpMUjry8ABdi+gAJE0zCL4bD0S3AZZQiHRrCNts9cCreFE7N4qvlHkqwGHMv4QEXw3HILP1XCz7emFEZ7DDvDuEhmJN4Wi2QdHQhvDFVKtM535Nfk1lCeuobhaGJC5uYydMWPcGc01gUaYpkkCdaDyvLd+2zki4sxLOBjJ5yZhn6/zf38WXoFes3JnjEihq4IKtoFwqxitqspAOFmjwUSmkR7cauDkuBgLL0PCNm1BUVVz8GwlWS2qTaelbSE5qUq1Lw9ud+i0aN36Bmdxt1S/7AlGO1VbKEyWgz1ZwR/tvtX/UPfJBXUll9gIyjAySRyoiWOYrc= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230025)(4636009)(136003)(346002)(396003)(39860400002)(376002)(451199018)(36840700001)(46966006)(40470700004)(316002)(40460700003)(478600001)(110136005)(47076005)(36756003)(54906003)(426003)(82740400003)(5660300002)(2906002)(8936002)(44832011)(70206006)(70586007)(4326008)(86362001)(36860700001)(8676002)(2616005)(40480700001)(82310400005)(1076003)(6666004)(186003)(26005)(7696005)(336012)(41300700001)(83380400001)(81166007)(107886003)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2023 11:41:49.8976 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9d44be54-1a94-4b10-f50d-08db005b7a6b 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: DBAEUR03FT010.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR08MB10085 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_035735_722721_5C8D15B0 X-CRM114-Status: GOOD ( 12.26 ) 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 We are about to add Realm support where the physical address width may be known via RSI. Make the Physical Address mask dynamic, so that it can be adjusted to the limit for the realm. This will be required for making pages shared, as we introduce the "sharing" attribute as the top bit of the IPA. Signed-off-by: Joey Gouly --- lib/arm/mmu.c | 2 ++ lib/arm/setup.c | 1 + lib/arm64/asm/pgtable-hwdef.h | 6 ------ lib/arm64/asm/pgtable.h | 9 +++++++++ 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/arm/mmu.c b/lib/arm/mmu.c index e1a72fe4..acaf5614 100644 --- a/lib/arm/mmu.c +++ b/lib/arm/mmu.c @@ -22,6 +22,8 @@ pgd_t *mmu_idmap; +unsigned long phys_mask_shift = 48; + /* CPU 0 starts with disabled MMU */ static cpumask_t mmu_enabled_cpumask; diff --git a/lib/arm/setup.c b/lib/arm/setup.c index bcdf0d78..81052a3d 100644 --- a/lib/arm/setup.c +++ b/lib/arm/setup.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include diff --git a/lib/arm64/asm/pgtable-hwdef.h b/lib/arm64/asm/pgtable-hwdef.h index 8c41fe12..ac95550b 100644 --- a/lib/arm64/asm/pgtable-hwdef.h +++ b/lib/arm64/asm/pgtable-hwdef.h @@ -115,12 +115,6 @@ #define PTE_ATTRINDX(t) (_AT(pteval_t, (t)) << 2) #define PTE_ATTRINDX_MASK (_AT(pteval_t, 7) << 2) -/* - * Highest possible physical address supported. - */ -#define PHYS_MASK_SHIFT (48) -#define PHYS_MASK ((UL(1) << PHYS_MASK_SHIFT) - 1) - /* * TCR flags. */ diff --git a/lib/arm64/asm/pgtable.h b/lib/arm64/asm/pgtable.h index bfb8a993..22ce64f0 100644 --- a/lib/arm64/asm/pgtable.h +++ b/lib/arm64/asm/pgtable.h @@ -21,6 +21,15 @@ #include +extern unsigned long prot_ns_shared; +/* + * Highest possible physical address supported. + */ +extern unsigned long phys_mask_shift; +#define PHYS_MASK_SHIFT (phys_mask_shift) +#define PHYS_MASK ((UL(1) << PHYS_MASK_SHIFT) - 1) + + /* * We can convert va <=> pa page table addresses with simple casts * because we always allocate their pages with alloc_page(), and From patchwork Fri Jan 27 11:40:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13118604 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 82FF5C38142 for ; Fri, 27 Jan 2023 12:21:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=AZayFl9+B2P5XtjWy0eTHDV0P9RGxHg8hoh/HwFd8dg=; b=uNRNAFtVqCrRoo 2BhUel7hd5aLXbrTcz6B/1yDizllicq1NLg7qkoJX18NknCDh4THMb3OFw/BDzmcrztODn+ze02Ls KeJgZBaR5DFRT9IA33Yrq7fkNUHGG4XiLxR8BxaWBM2/IZXoyi6c0JqMdMT6y+H8HRI8lDj9yCqgA 9WHOWPhKhKmZiMpa4G4AlZ9vXv0J1iA+lODMAfmIiMAY9r5jt/h8Aazek2xl0Q5jhKQY8uaFFiXeu lbCRkKmKQC2UMx9Q6/+Y1QY27CfCEpUowTNtz8A0cRzoo/iSFYO/gdd7ZDme3oY4LV7EooMlLvBZo i1MyEtFxdw502lsTha9w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNiO-00EVNR-HK; Fri, 27 Jan 2023 12:20:21 +0000 Received: from mail-he1eur04on2088.outbound.protection.outlook.com ([40.107.7.88] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN7J-00EDkV-1c for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:42:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SFNQAxSU7XAJtJhJFGLeQLPoIFHCEXEJJzjwvGAuSAo=; b=3KMDKRZwFWb9ItNkbUaQhuGI41XuKkUT4DSbqUMi614rMCTgaTLpG/16qVo9FhAqVB9PWiaMkS2IoI3SkgRMlPVdVQyqiO8MunblxaDgPqKL9scwX6fQPp7N7L9/6bCc/S6T+wHQ3oQyocuLb/a4NW8YzXEALI3bDvXdcWflQPM= Received: from AS8PR04CA0087.eurprd04.prod.outlook.com (2603:10a6:20b:313::32) by PA4PR08MB7410.eurprd08.prod.outlook.com (2603:10a6:102:2a2::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33; Fri, 27 Jan 2023 11:41:55 +0000 Received: from AM7EUR03FT060.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:313:cafe::df) by AS8PR04CA0087.outlook.office365.com (2603:10a6:20b:313::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23 via Frontend Transport; Fri, 27 Jan 2023 11:41:55 +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 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM7EUR03FT060.mail.protection.outlook.com (100.127.140.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.21 via Frontend Transport; Fri, 27 Jan 2023 11:41:55 +0000 Received: ("Tessian outbound 333ca28169fa:v132"); Fri, 27 Jan 2023 11:41:55 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: ec865946f5b87296 X-CR-MTA-TID: 64aa7808 Received: from 496d2b36e9b2.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id A7413008-086D-4EFF-988E-873B3B9F265B.1; Fri, 27 Jan 2023 11:41:48 +0000 Received: from EUR02-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 496d2b36e9b2.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 27 Jan 2023 11:41:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HSlpimX2uVn1xq7nvWgwXNkUfk8Z0aXIQxhaU1ANcUn7wlerGMBPMyF2X3CqezsF28ZL6VSfSrNHRE5ARI/kkiXC8VwnI25epJJF5q9x9CVngpocvZ4BZwmoe/5J5eOrFpSNKwslUA+8zsn8Fn55mC2xGk5k9Y5UaOl3qMV/DonvcrgNBNmLMLzCD3MJB9TNl139rSi+G0gnL424Ca6LynKD6SzkNxlpd/getnLpVJeud7ec+K0sZQFjaxB2sBMCuPqI6s3g1SAZN5+9eKZ8Og0XUt9MLMioLfhLpAmdd0vgrBktGRfBWsoy8mwdNAJ5elpalpzS224ZsZ42rOxteA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=SFNQAxSU7XAJtJhJFGLeQLPoIFHCEXEJJzjwvGAuSAo=; b=RecQWZn5VyHaYQmJZGmcLEepxfJwIG2T5K3oSZp7H1AqTiMTff83yq5s1IFiL+OdCMXPPx+6dWLfqDsb3R1Et97IIltGrANk/bSNilE59fUZ99rSWfIbZfTBFHb+0BIiAdWtHRqoD4bWfMK1t598K9KAu+AWf/rda0SAD/fpRofIdwRT/Nf/7t0SN9fvtAsL0WwTGr1UgCL4jFIi7U3jz/JDIvwxVZIpHnmd9D/W6HLHlay+CIOmIVvidw7GcWwoI7p4RIl4uEXjv+Teyw2wMxAhIjFhwb0My70lncuUKyq2cJfdNbTV/DHK5roRNWGthbCCHVbI2UTcdXwmz0UZcA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=linux.dev smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SFNQAxSU7XAJtJhJFGLeQLPoIFHCEXEJJzjwvGAuSAo=; b=3KMDKRZwFWb9ItNkbUaQhuGI41XuKkUT4DSbqUMi614rMCTgaTLpG/16qVo9FhAqVB9PWiaMkS2IoI3SkgRMlPVdVQyqiO8MunblxaDgPqKL9scwX6fQPp7N7L9/6bCc/S6T+wHQ3oQyocuLb/a4NW8YzXEALI3bDvXdcWflQPM= Received: from DB6PR0801CA0043.eurprd08.prod.outlook.com (2603:10a6:4:2b::11) by GV1PR08MB7682.eurprd08.prod.outlook.com (2603:10a6:150:61::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23; Fri, 27 Jan 2023 11:41:45 +0000 Received: from DBAEUR03FT030.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:2b:cafe::4b) by DB6PR0801CA0043.outlook.office365.com (2603:10a6:4:2b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.22 via Frontend Transport; Fri, 27 Jan 2023 11:41:45 +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 Received: from nebula.arm.com (40.67.248.234) by DBAEUR03FT030.mail.protection.outlook.com (100.127.142.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6043.23 via Frontend Transport; Fri, 27 Jan 2023 11:41:44 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Fri, 27 Jan 2023 11:41:44 +0000 Received: from e124191.cambridge.arm.com (10.1.197.45) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Fri, 27 Jan 2023 11:41:38 +0000 From: Joey Gouly To: Andrew Jones , , CC: , Alexandru Elisei , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Suzuki K Poulose , "Thomas Huth" , Will Deacon , Zenghui Yu , , , , Subject: [RFC kvm-unit-tests 05/27] arm: Introduce NS_SHARED PTE attribute Date: Fri, 27 Jan 2023 11:40:46 +0000 Message-ID: <20230127114108.10025-6-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230127114108.10025-1-joey.gouly@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127114108.10025-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT030:EE_|GV1PR08MB7682:EE_|AM7EUR03FT060:EE_|PA4PR08MB7410:EE_ X-MS-Office365-Filtering-Correlation-Id: e0c3f790-5586-4d7c-a4bc-08db005b7dd0 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: nXh9nliPOvPbK7iNWdfQJGaAOWXzyeT5xP272oeXMQ9wIlN/pix2FVmcYcMy9nDWaq/OkvqSyBVXc55g49cWYD6Xhr6cWFfHF/0uEYL10iFdgj/qkC4BIaFMA5oxfivwOz7d1bBlhIVTG+DqbusvWuj4fBifty806bpuD44d3lpGQSJrd56jZBN9uHdu5qx4ytc7vEiSNGrZ+18JdL0P40iRHq/uq83+sWygUotByfqK/9KBTqt3NKkc9WSI/YZgxd3o9pSAfH7l8t3u1uqMdE/FN29YZ+drzkyUWoMnlikkWs9OSPzMfR3VjUQsWGFYumhKrotfZK90x7fhs7d5uR+8ShN+DXYs1NPQj/PpaK3tdyrGAl62T8lcmin4kEwCgbnnlXe1RKZkZ/pF4pTkO9Z1xh3hZipZr52rZX4KVOW3ZIZ8KSDirXNhp49vvtT7RV6iNZQ3OzQsu6u5wpoLprBbBCa83pJe+ZBP0PYOgMNxIzUvoiC+LsGQukDOaleWpueHjB8abYeLGp51GmmegorsCaGpPclUby0k7KvWFF/0BbWZ6RqiNFCIkc/vXY0o1jwlhi3MAzJ+TgPyww8n/19y2KTpCf0SRrY6huTOiUULMpIyNFY1MPdg6KqRa400jPYr7BDKsBGLskLI/Qb06DyXIlb/SM8mbHg2ZWh56hA8xZO/eWpLIDPrkRGjNk/zuJeG/gkwDza51yvzMo2cta4NtgWSqJul9F9rpskEs4KEyjcLgv3dKTnqPX0wHp1R 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:(13230025)(4636009)(376002)(136003)(346002)(396003)(39860400002)(451199018)(40470700004)(46966006)(36840700001)(356005)(2906002)(44832011)(5660300002)(7416002)(81166007)(8936002)(41300700001)(6666004)(86362001)(478600001)(40460700003)(83380400001)(110136005)(36860700001)(54906003)(82740400003)(316002)(82310400005)(47076005)(426003)(336012)(40480700001)(36756003)(2616005)(7696005)(8676002)(70586007)(4326008)(70206006)(1076003)(186003)(26005)(2101003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB7682 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT060.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 13603eb6-22e3-412e-8705-08db005b776a X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BeS/pCIPu3MdaRcoTIc81dIyMqLkeH5uUynwNEs5FeEmWcOjupxZNVzYDPrDyhaFTG/wnAj9jSONFCI9evSzzn4VO6sBP0zqfNUhDj44SO+LNj0hqcKrnS40jPPBazuLmFmfOYFG6sB9ttq/cZA6HmXMAog80w5LxjTfTpIe7d4fUwwAV5ifuHoFTDu7Gv5+itGTGgK2KVW4ZCHVEQci0esw3zXdpESCWW1EiLRfs65JGrDyL7+D/tlG0RWzXS/RLFLTGY6/5BWPpJ17HC4UGoOy88t/1MW4NY+qrolRgdRH3wK91VuOUJZSDtukNfw5uim70i8j6OrmnPdns6R6/5kwz4upBoxUmNJZ8C9M35WvKY2A2mmeb8qdyvb9Z5xAaQyp1GivA5afetiwh2Qfwar4v/hQZvV0lwRzEYtVcuL6+gCHRcQThl0+CqH8Q9p1ocLIYKmTSNcrSFV/ZpEZg6LD9/1sXRECU1Bux1Kabw+rsqxyRm6/3PE/mhAqnxUk6wkqFeQVTSt33GeSi+MC8TYn93vFbtGdRhkp33NerEJ3oGv7uzQKXQdN0dGRUQHpa2npkraNh/4s7CBaLGaB90NO5WLlYy74fW/f1WxsbB0l70H+mV67ThH6lw4yJUDgrZREsDhyy21GN0ohr6GK+5ZyYLPIx69hP331PjtBvyDSdubWzJI32FkYX9wHx6CYqymA8nNTBHj9yXubT4H4zdfA6xUxmLYM8qHefwWLm9k= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230025)(4636009)(396003)(376002)(346002)(136003)(39860400002)(451199018)(36840700001)(40470700004)(46966006)(6666004)(8936002)(107886003)(5660300002)(26005)(478600001)(83380400001)(186003)(54906003)(81166007)(2906002)(1076003)(82310400005)(336012)(41300700001)(8676002)(86362001)(82740400003)(2616005)(110136005)(40460700003)(70586007)(4326008)(70206006)(316002)(40480700001)(47076005)(7696005)(44832011)(426003)(36860700001)(36756003)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2023 11:41:55.5281 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e0c3f790-5586-4d7c-a4bc-08db005b7dd0 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: AM7EUR03FT060.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB7410 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034201_177184_F90B86A6 X-CRM114-Status: GOOD ( 14.04 ) 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 Introduce a new attribute to indicate the mapping is "Shared" with the host. This will be used by the Realms to share pages with the Host. For normal VMs, this is always 0. For realms, this is dynamic, depending on the IPA width. The top bit of the IPA is "treated" as the "NS_SHARED" attribute, making the VM access the unprotected alias of the IPA. By default, apply the NS_SHARED attribute for all I/O. Signed-off-by: Joey Gouly --- lib/arm/mmu.c | 5 ++++- lib/arm64/asm/pgtable.h | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/arm/mmu.c b/lib/arm/mmu.c index acaf5614..6f1f42f5 100644 --- a/lib/arm/mmu.c +++ b/lib/arm/mmu.c @@ -22,6 +22,8 @@ pgd_t *mmu_idmap; +/* Used by Realms, depends on IPA size */ +unsigned long prot_ns_shared = 0; unsigned long phys_mask_shift = 48; /* CPU 0 starts with disabled MMU */ @@ -194,7 +196,8 @@ void __iomem *__ioremap(phys_addr_t phys_addr, size_t size) { phys_addr_t paddr_aligned = phys_addr & PAGE_MASK; phys_addr_t paddr_end = PAGE_ALIGN(phys_addr + size); - pgprot_t prot = __pgprot(PTE_UNCACHED | PTE_USER | PTE_UXN | PTE_PXN); + pgprot_t prot = __pgprot(PTE_UNCACHED | PTE_USER | PTE_UXN | + PTE_PXN | PTE_NS_SHARED); pgd_t *pgtable; assert(sizeof(long) == 8 || !(phys_addr >> 32)); diff --git a/lib/arm64/asm/pgtable.h b/lib/arm64/asm/pgtable.h index 22ce64f0..5b9f40b0 100644 --- a/lib/arm64/asm/pgtable.h +++ b/lib/arm64/asm/pgtable.h @@ -22,6 +22,12 @@ #include extern unsigned long prot_ns_shared; +/* + * The Non-secure shared bit for Realms is actually part of the output + * address, however it is modeled as a PTE attribute. +*/ +#define PTE_NS_SHARED (prot_ns_shared) + /* * Highest possible physical address supported. */ From patchwork Fri Jan 27 11:40:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13118654 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 92018C54EAA for ; Fri, 27 Jan 2023 12:55:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=jdTpB6OsczEnGpfOrRimbP17G0O5XfqIDxSMUhb7Mmo=; b=l0fJoz7MVFdTk7 mkKi9H76LF8P9LzL9x+DXtb/i7UisO5cBqS+i+s2vTVY/HuHp79whDM+Vx0P5cXsawXeV6cducTp8 1UhOdCHpkTWIHLza0Y8zhi2U8wvVALMR3xSsZIWYjH2RAj1lXQ3/aZYJnZI91Mb2F/eJ98rNTWsCS oXc7ooyC4atBMqh/lAeDz2VMdZNOgsjzdI+maM8l4TphZEZQvNHVINqiRW5oyxKry8PVC/l8UcjTr vMsGlxHauPAFpQ8JmpuNqA06D9+gz4AaIIfRT5THKO1BlUGhpdaG9Nq/CKYMf6LHXDEHfwPmryyid 2b1oZ/tsdFE6/zPeJq0A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLOEb-00EjlS-8m; Fri, 27 Jan 2023 12:53:42 +0000 Received: from mail-am6eur05on2061d.outbound.protection.outlook.com ([2a01:111:f400:7e1b::61d] helo=EUR05-AM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNLw-00EKWM-Gr for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:57:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SYzPSw73nqKSU8OhYrjVNXKg3dYyCW6HR+r91vpgRZI=; b=0rcSzAS2O6vh2ccQf3/wOqkjhAtByy4jyA8gm56RXovtyCCrbszOgILf+u6LLRBIt72b4UNw4zd1wEnNG8U4e6XK6OmHf3Vf/5IxGswe21OfFQ0RP+C30kMRfxkztrZ2JqMhmjSbl+TO0trFyz7XpI4S54fQhZTSiCZxuQIWOpA= Received: from AM6PR10CA0044.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:80::21) by AS8PR08MB9718.eurprd08.prod.outlook.com (2603:10a6:20b:616::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.21; Fri, 27 Jan 2023 11:42:03 +0000 Received: from AM7EUR03FT063.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:80:cafe::2c) by AM6PR10CA0044.outlook.office365.com (2603:10a6:209:80::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23 via Frontend Transport; Fri, 27 Jan 2023 11:42: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 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM7EUR03FT063.mail.protection.outlook.com (100.127.140.221) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.17 via Frontend Transport; Fri, 27 Jan 2023 11:42:02 +0000 Received: ("Tessian outbound 8038f0863a52:v132"); Fri, 27 Jan 2023 11:42:02 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 77784d72f3ea9004 X-CR-MTA-TID: 64aa7808 Received: from 44e899167353.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id D44DE00C-0BF8-454E-8529-A3E63B0D0CC9.1; Fri, 27 Jan 2023 11:41:55 +0000 Received: from EUR03-AM7-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 44e899167353.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 27 Jan 2023 11:41:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nEn2RLLbP5bpOeUfueR5cKF8j6ftxy5Ug9egrz5aQZHzQvxbnY4iIy6KomwH7yOr/iSWe6jx6adBgUURJNVXQnjtxXr/Ago1fjjB/mj1n3SZkgc8pgsGC6hoTs5lX5oPNAn2RnMsuaTm0tYv7dnHTncQhA+DVMmRKxgIaBv4aFp4clexqQxoEYQ1+O4yfv/rf06NUuNm4z48ZSM9csv2xAohukEMGEGWGSbRg19CmerMrTKJHsBQj3hw0NLrUpoCAKWkqOlUER1B7LnomJoLoh6SoI9jR9rZBqQcNB2TfCmTgC3hz3Kr9Kj3Igt19TRHr+MYRiUquvGWK/QEQCItwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=SYzPSw73nqKSU8OhYrjVNXKg3dYyCW6HR+r91vpgRZI=; b=UpCxtzJC0O2vfYDfs43Lk8uQ6TAGWeooYG417tkxmDfLTURjrAvOoYWZOqlC367l21+Sljsh70I2pICZljDuPNKApF5o1Jh8MHl0V6VahQPSGWZogAG7IeRvncsHzw7FkfQEY70Y9pY9O19WfNVWfF/f8pCswiCG5Z7CFuTZq2F+6I9PYJXVTUZc5jR/uvcKJt8n55DQ9pVbTWv28JIh1deZKOlN+6U2MK0V4mhPeIez8vl3Jbe9E2wU+bii1j9yimVpEZn4sbiZKIudfEZ+4N+wJtaL6PTn2LKlk61U5gX7RHc3Rgtj36ahzOIA40oqd9UHvwiTbouOxcwkVdCbzw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=linux.dev smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SYzPSw73nqKSU8OhYrjVNXKg3dYyCW6HR+r91vpgRZI=; b=0rcSzAS2O6vh2ccQf3/wOqkjhAtByy4jyA8gm56RXovtyCCrbszOgILf+u6LLRBIt72b4UNw4zd1wEnNG8U4e6XK6OmHf3Vf/5IxGswe21OfFQ0RP+C30kMRfxkztrZ2JqMhmjSbl+TO0trFyz7XpI4S54fQhZTSiCZxuQIWOpA= Received: from DU2P251CA0003.EURP251.PROD.OUTLOOK.COM (2603:10a6:10:230::13) by PAXPR08MB7491.eurprd08.prod.outlook.com (2603:10a6:102:2b6::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23; Fri, 27 Jan 2023 11:41:50 +0000 Received: from DBAEUR03FT024.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:230:cafe::86) by DU2P251CA0003.outlook.office365.com (2603:10a6:10:230::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.25 via Frontend Transport; Fri, 27 Jan 2023 11:41:50 +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 Received: from nebula.arm.com (40.67.248.234) by DBAEUR03FT024.mail.protection.outlook.com (100.127.142.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6043.21 via Frontend Transport; Fri, 27 Jan 2023 11:41:50 +0000 Received: from AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Fri, 27 Jan 2023 11:41:50 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) 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.16; Fri, 27 Jan 2023 11:41:49 +0000 Received: from e124191.cambridge.arm.com (10.1.197.45) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Fri, 27 Jan 2023 11:41:44 +0000 From: Joey Gouly To: Andrew Jones , , CC: , Alexandru Elisei , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Suzuki K Poulose , "Thomas Huth" , Will Deacon , Zenghui Yu , , , , Subject: [RFC kvm-unit-tests 06/27] arm: Move io_init after vm initialization Date: Fri, 27 Jan 2023 11:40:47 +0000 Message-ID: <20230127114108.10025-7-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230127114108.10025-1-joey.gouly@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127114108.10025-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT024:EE_|PAXPR08MB7491:EE_|AM7EUR03FT063:EE_|AS8PR08MB9718:EE_ X-MS-Office365-Filtering-Correlation-Id: be5b2893-2319-47d6-866a-08db005b8236 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: hhxDnclshnX25RNw37UaJ6Bq5plaxqtvfEi/qSoa/Tim7E0yWsug7K/p0omEoD40wA2Br0iQ6bD5JHfoCbo46PI1vHkZeRFBorN9wl2sG8+08+AVL+W1AcXUZLVlTe+qkeJCaP48cJp5gbY2qmnbAE3kbCfTGZh2HRMRr4j4zsEQifRG6o7zoM7/qJ2B/rpNB5gh17nRDhs7jbdyswjqI2CInQJyVRoWJR1W6DCbVY5PrDY/im5t2lasVyDIyxevpfz8rUwwhE9Y2JDpGqVSepkCBZBH2Mtz4cVoKFoDL8vzADx08hH/ZOwI1s9D0Fu5Jm2kc786lR3GQiIYTC7ixPX4Hxwa22tFMSMyel1fahDELJk88K0QoCQTtGt1baKQd5pqB+O8COt1Dbqbvxbd9aDG6ZHzsUJcOuqBC+f/xwfuBWE21+uzI0i35EqK1Wi9YnWwS1ip1uB0u0lf0Oif1OFMZB4h57fBwIukdSlzJL9alutczRM/89VlpYQPyZ+e9RUd+bd0L6LkxAu177v9evodF1lf60u+D2mrDezP+1/l9lpgVeuxaAC0oVTdJbB786rogMCiaCcWED1AfkKxTcT6S5CtQ6cqvmu3CPAjOaJ+4XJBG3ZIrtT/6lwZZ2AxZ2rgIMp2QxMFCCxsGJ8CwVaiVH02wDhEhNpPFFJT+KpTJVv1Dnj+t36iNoe9abjFBKdOGunXmp3AFMW7Wp+UORQd7NLavVZi+dVvTKyC0H4Txy1YCatsB2Gq3wEsom41 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:(13230025)(4636009)(346002)(39860400002)(376002)(136003)(396003)(451199018)(36840700001)(46966006)(40470700004)(44832011)(7416002)(2906002)(40480700001)(82310400005)(36756003)(110136005)(47076005)(426003)(7696005)(54906003)(83380400001)(186003)(1076003)(40460700003)(336012)(26005)(2616005)(478600001)(86362001)(70586007)(70206006)(81166007)(356005)(8676002)(8936002)(5660300002)(4326008)(41300700001)(316002)(36860700001)(82740400003)(2101003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB7491 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT063.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: a6b2f3e3-fb2e-496a-00cb-08db005b7ae3 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3UBC1KsXitFtpB0QBl9H0hw5OwVAsmxwsfs8lMDAcIBYeB8/NE9Eh92ix9Yw6IJrK6SdDfmv8MtjsL+Wiyj8sKByCPCf8/lzwP3meNOW1iXqy07bl9TM7cuo1/rs2K5vCIGlRSGQbh0DPQbJrYTHEQKIDkv4qgUE9pgEjdriJIJtcLV81/QbaoPjeyXcUObU2lApLoGCENSiDiO/YOi4qzC0o0Xi+BoiS/SXyqY+DQjQBvunicpPnuDv1RgSMvXVTmihpfGyNZkztWZo0FVbM18EQolC+jJ4mxRjkjk5r/4lhC/i8zbE/YSzGyWQgsN6ASq4AXGW5tdnOBoxRHK3T13M0z2wUKJIY6seFq7JTevLRLyQ6Z0hPxEXpmxvIexTF9Nga6zyRf22d8n/Se3BJTTx3fd80MaksVk1paq9U4tTsFFVUeNvQFJYT7QhKxEjQG3WWcZq/fPX7g4hTE5NjJSBAchLBGiAMVeOoaTmy4EULa9Pgl70LD+iyvkdBavgL4lZCyRdICUqEgWSNHao/Ln8DqwC0S0i+yO5ROLDUyjsUKxiuRYtfzkSF++oKhZfk4x1IaMZ8Gwma+IfMfll7wwOjQM544v86L0TIjTeBrEe8V32aVrXwCXuDMErPIak7QAJnn2Xn2qyKBlrKTJ2Zu5d8anYRe15gbg3hf+SbqISkMU5/WSRUWkATKsPDqWbdV1j9ZA6LiySXLZvQBk1JNOsaSb5FizcY4kYwM3Z1Yk= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230025)(4636009)(376002)(136003)(396003)(39860400002)(346002)(451199018)(46966006)(36840700001)(40470700004)(44832011)(86362001)(54906003)(110136005)(40480700001)(107886003)(1076003)(2906002)(40460700003)(2616005)(26005)(36756003)(426003)(47076005)(336012)(7696005)(186003)(478600001)(83380400001)(70586007)(4326008)(41300700001)(8676002)(82310400005)(5660300002)(70206006)(82740400003)(36860700001)(316002)(81166007)(8936002)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2023 11:42:02.9067 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: be5b2893-2319-47d6-866a-08db005b8236 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: AM7EUR03FT063.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB9718 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_035708_582929_99AD391D X-CRM114-Status: GOOD ( 12.71 ) 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 From: Jean-Philippe Brucker To create shared pages, the NS_SHARED bit must be written into the idmap. Before VM initializations, idmap hasn't necessarily been created. To write shared pages, access must be done on a IPA with the NS_SHARED bit. When the stage-1 MMU is enabled, that bit is set in the PTE. But when the stage-1 MMU is disabled, then the realm must write to the IPA with NS_SHARED directly. To avoid changing the whole virtio infrastructure to support pre-MMU in a realm, move the IO initialization after MMU enablement. Signed-off-by: Jean-Philippe Brucker Signed-off-by: Joey Gouly --- lib/arm/setup.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/arm/setup.c b/lib/arm/setup.c index 81052a3d..65d98e97 100644 --- a/lib/arm/setup.c +++ b/lib/arm/setup.c @@ -274,9 +274,6 @@ void setup(const void *fdt, phys_addr_t freemem_start) /* cpu_init must be called before thread_info_init */ thread_info_init(current_thread_info(), 0); - /* mem_init must be called before io_init */ - io_init(); - timer_save_state(); ret = dt_get_bootargs(&bootargs); @@ -292,4 +289,7 @@ void setup(const void *fdt, phys_addr_t freemem_start) if (!(auxinfo.flags & AUXINFO_MMU_OFF)) setup_vm(); + + /* mem_init and setup_vm must be called before io_init */ + io_init(); } From patchwork Fri Jan 27 11:40:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13118605 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 7C259C54EAA for ; Fri, 27 Jan 2023 12:22:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qmHPyzfiQ3UTIqGQd4fAF9brBkFxFnPUDGJVaSjCmBA=; b=l0gmnVnkAEi9Y+ siQpv/Np3TKX61zUqo9Wpt8z75s0D25KAb6vIQMUwdYoAjxsNAIebfw2eZ00LTnzJsikuaEKpSu2w 7y3mTu+jqJ4s7REvbS7c0+Ej8fZgj0elR6uKmspCuCjSBfUEwIui7M+sA9AR7FhV3U+FmoQIjOR+f S0juWOTmYJigOb7TyvdeMyQzrNco+pYlzu17x+mngBGGMqp7yz5RIUQ+/U0U1FIz7zeJsNZz3jql5 c4pYsC1wJftSRyG2vwsHlkr4CMdq4XJUnQVagqzqskeafSyHZVpdh7MZ9o59I1yZ7HVj934XdfCqI utU+XaEABIzrNUyugpbw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNj8-00EVkc-Ry; Fri, 27 Jan 2023 12:21:08 +0000 Received: from mail-db5eur01on0608.outbound.protection.outlook.com ([2a01:111:f400:fe02::608] helo=EUR01-DB5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN7V-00EDrB-Fv for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:42:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=J0EaVl7U6Q2PCuIAajE8wsA6jxr+3lwL//SWR9QcSOM=; b=cjqlq1rZtMcDMTUZRxAc5QNL9pXbuUDa4EYv0HCchCavocC6A3e4pSvvYBgChcG8krMY+ahIomgJ3rZr9xSPej5OfbB8uHduhYLN8X3NRxwVNCt9SV3p88tclvjm4hpCApjpBz9YsUm9sy0PhaNcdDj+L0ekJDNjuCronUqXv/A= Received: from AS9PR05CA0134.eurprd05.prod.outlook.com (2603:10a6:20b:497::11) by DB3PR08MB9136.eurprd08.prod.outlook.com (2603:10a6:10:43c::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33; Fri, 27 Jan 2023 11:42:08 +0000 Received: from AM7EUR03FT035.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:497:cafe::c7) by AS9PR05CA0134.outlook.office365.com (2603:10a6:20b:497::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.22 via Frontend Transport; Fri, 27 Jan 2023 11:42:08 +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 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM7EUR03FT035.mail.protection.outlook.com (100.127.141.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.21 via Frontend Transport; Fri, 27 Jan 2023 11:42:08 +0000 Received: ("Tessian outbound 3ad958cd7492:v132"); Fri, 27 Jan 2023 11:42:07 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 996d8be9c24d118f X-CR-MTA-TID: 64aa7808 Received: from f27dfe4e57cf.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id B2F886A4-2F3B-47B0-B71C-5A76E8E5CCC0.1; Fri, 27 Jan 2023 11:41:59 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f27dfe4e57cf.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 27 Jan 2023 11:41:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OsFuiyLcOAjXuAc2Gk9lDrhLA7vrGNstQ8hhVcGsHS5NytUHPimmr4U7JLyPMPlP3STmO1lldTtv1PzTQU1zRqeD/tgpzZMgqVAFJnEV0wAj6pYXqwP7KhCikG8bhjaRWNZXN2lOUefXV4wzt0FwiQnF1lAjqX/p2LxgPzSIilExnjY9YuY9cHN3JPe1YUUN76EhWaSod02+8CkwyVjq3texIZomXhJuWKHKMGleQfiUkDY5X467nc6hi6GfmvXs6Mruvemdy4+NkD0mGekvJcBwxlYK0K7jDGosVzN5HCyAgj24IT2L0xB/p/1V4iiFe0O1C1Ihm5JXCh2wgbUsEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=J0EaVl7U6Q2PCuIAajE8wsA6jxr+3lwL//SWR9QcSOM=; b=Tww42ACJ+XL1uLPNsPRvV3uKtGgPwbZrwoBfqmWyGnm7+GvoQZUiCN8Z9ZfbJNc00hv442hCF0we2EZQBR0gorPQtb9Xn9I81hSu8ekEcnmp+d28REKOrdYIn8s8+vn2cFVebLD4HNND6PiCFL4cS2DSRYXl9Oi8tCDSTqbSuaiO4tG4SAciVmMUj6YeALWd0ev+b4jA13kOIAz9665avJScpHsmPNHX1iTxDgkz0HmXaid4FaOMl8yijeDJus7CItXZK/969hAD7sR857X2jUNenPK3+5DTgJpcvBe4DyO+zcYVAcnyaaYMqjroZUCSOAxUBde5sQi9PFOoCvOiqQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=linux.dev smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=J0EaVl7U6Q2PCuIAajE8wsA6jxr+3lwL//SWR9QcSOM=; b=cjqlq1rZtMcDMTUZRxAc5QNL9pXbuUDa4EYv0HCchCavocC6A3e4pSvvYBgChcG8krMY+ahIomgJ3rZr9xSPej5OfbB8uHduhYLN8X3NRxwVNCt9SV3p88tclvjm4hpCApjpBz9YsUm9sy0PhaNcdDj+L0ekJDNjuCronUqXv/A= Received: from AS9PR05CA0079.eurprd05.prod.outlook.com (2603:10a6:20b:499::19) by DU0PR08MB9797.eurprd08.prod.outlook.com (2603:10a6:10:446::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23; Fri, 27 Jan 2023 11:41:56 +0000 Received: from AM7EUR03FT011.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:499:cafe::cb) by AS9PR05CA0079.outlook.office365.com (2603:10a6:20b:499::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23 via Frontend Transport; Fri, 27 Jan 2023 11:41:56 +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 Received: from nebula.arm.com (40.67.248.234) by AM7EUR03FT011.mail.protection.outlook.com (100.127.140.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6043.22 via Frontend Transport; Fri, 27 Jan 2023 11:41:56 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) 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.16; Fri, 27 Jan 2023 11:41:55 +0000 Received: from e124191.cambridge.arm.com (10.1.197.45) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Fri, 27 Jan 2023 11:41:50 +0000 From: Joey Gouly To: Andrew Jones , , CC: , Alexandru Elisei , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Suzuki K Poulose , "Thomas Huth" , Will Deacon , Zenghui Yu , , , , Subject: [RFC kvm-unit-tests 07/27] arm: realm: Make uart available before MMU is enabled Date: Fri, 27 Jan 2023 11:40:48 +0000 Message-ID: <20230127114108.10025-8-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230127114108.10025-1-joey.gouly@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127114108.10025-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT011:EE_|DU0PR08MB9797:EE_|AM7EUR03FT035:EE_|DB3PR08MB9136:EE_ X-MS-Office365-Filtering-Correlation-Id: eedea81f-9ca1-4b8a-ba22-08db005b855f 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: Tvq4CII9rffgM6JmDFn9otSRzZulxa51tR8cXthwkUoTaT5Pkf/PylpIs8UfcsN4LC3NQ1YWmJeLBfNkpfZjc5xDw4593sXWPxrvDiONMpKqp44AqgIQw1HbKWIEURf8SZ8P/gnCPbjWAPDU4jsPa2SiD0g/rBVgAHxLaJyTk1w53AccUlvYrlWMwV7EctqdjXn4GrkuvCWxcg6lerPs0gqxcMWeqRjX+BR6UxpMG/yazshjzZYc3mnH82OJLt/DI8I4XL8147GqfIDOiDI6XEjeuyUvERoBO7htyc0lr9Ej9X7IeFUDFFBV0p5aqouLARjdqN7GaqDORurQJQC0zl9CRavHWCk+s27ur7MoTEaECnVWJdb5JPmJe1uEBsXo8IrXZXDEcRTqWt450zshd+eA1eJz8vhqQ0/iY97+QHjy8M4jZmhL+9cHsoMaTpR+7F80QWsAxw8V9ChsCl2JGZbUBg5iSCDDXh9VRrTj5wTY77dNQiPsWPMCO9br4Ofi/U6535SoYDqssN4BRdkF/U4R06vOfaazhn6fN4m5HXcjJG3GzsXZP72pi8qVWTYkt89xSMNke9X2dmz2SyRVQLJCo/OwoOjUdlGCl7JLqYQuoENCPDR4I2x6Jt0yKNAanlxjKAwoSu75C+Le980yRE3aXjmTvD1qFdn40owd0/9qjGlLougxxLylpwy/9ePjStmDwmJjmuxtDgYD2g4wlN8V5qVnCU8RBu/Oyb1nRGciSmnAUS+FTucfkJrYI74r 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:(13230025)(4636009)(396003)(376002)(346002)(39860400002)(136003)(451199018)(40470700004)(46966006)(36840700001)(70206006)(4326008)(70586007)(41300700001)(8676002)(83380400001)(54906003)(8936002)(316002)(5660300002)(82740400003)(110136005)(2906002)(81166007)(44832011)(36756003)(40460700003)(40480700001)(356005)(7416002)(36860700001)(47076005)(426003)(7696005)(336012)(478600001)(86362001)(1076003)(26005)(82310400005)(186003)(2616005)(2101003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB9797 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT035.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 2ac69784-e906-45bb-db95-08db005b7e5d X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6Ry2eAFL+q/IxddEJniTkJZxp799sCN3U5/SP50piqy0A55eugoow0m7/qsIituOSe7vEmOhVOa3lwohBu2cx42fiWBzbVk37vd+egRid/xMfupFsKgHg230ixiSXj0cgYYU6hXyWxPceq9YX9luJAfp3sdgGNJMi0vnscm+qirZWpowyvNXNhYZ3e7hxKTk2a1vG0rEqPYweVp+Lh/NWdxn8FZ+RyC/Jays67zboZ2q666LpTZXrltTOydSfk/DUviux/PANvVEfdCjRQnM5kbOYMhenTedKL+iEDsv3HcUqBvmmu2DOnL24dIggfkaPEEm9TLg+YYCf/erM+TwLvMStQLwpaXIDLkW0JZwAnW4dFbw7ca0R7RygS7x1bngT2Be9LMiriuc4E2unRajQ0RZe6CQlqPG6dVADPuCODNcHVd2QDFK0iihq7mH5QLs7ZB8n+yDU3GJUFgY0t88/A5L7CyepWe9opnDaSWhIECHFo/jpY+GP/ruKaLxekKWZTBnTB40MVAuq9L6ijles9mVJesWKO8/BZ/xMq7t7GLXSmhV9FypA9Q3utejMWw6ELVVmRxEeqDcc59MZfpVVwkvy110bI8RDWo87KRw5qOP1WADJkVZn84hX/11Yqc+lV68+Mp70HZO/ey62vJuRIqUQIdcHxHCBwySAU8HL69qifaPV5TCv9m4FfW4PAbh2D2W81u99fJhWVYIkhyQL/7dpnkI7POCeIntw7sJ0Og= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230025)(4636009)(136003)(396003)(376002)(39860400002)(346002)(451199018)(36840700001)(40470700004)(46966006)(8936002)(4326008)(47076005)(41300700001)(5660300002)(2906002)(336012)(478600001)(8676002)(1076003)(186003)(86362001)(316002)(26005)(54906003)(2616005)(83380400001)(36860700001)(36756003)(40480700001)(107886003)(44832011)(82310400005)(70586007)(426003)(82740400003)(7696005)(40460700003)(110136005)(70206006)(81166007)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2023 11:42:08.2099 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: eedea81f-9ca1-4b8a-ba22-08db005b855f 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: AM7EUR03FT035.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR08MB9136 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034213_602624_EC89025A X-CRM114-Status: GOOD ( 17.14 ) 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 A Realm must access any emulated I/O mappings with the PTE_NS_SHARED bit set. This is modelled as a PTE attribute, but is actually part of the address. So, when MMU is disabled, the "physical address" must reflect this bit set. We access the UART early before the MMU is enabled. So, make sure the UART is accessed always with the bit set. Signed-off-by: Joey Gouly --- lib/arm/io.c | 24 +++++++++++++++++++++++- lib/arm64/asm/pgtable.h | 5 +++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/lib/arm/io.c b/lib/arm/io.c index 343e1082..f7c6c771 100644 --- a/lib/arm/io.c +++ b/lib/arm/io.c @@ -15,6 +15,8 @@ #include #include #include +#include +#include #include "io.h" @@ -29,6 +31,24 @@ static struct spinlock uart_lock; #define UART_EARLY_BASE (u8 *)(unsigned long)CONFIG_UART_EARLY_BASE static volatile u8 *uart0_base = UART_EARLY_BASE; +static inline volatile u8 *get_uart_base(void) +{ + /* + * The address of the UART base may be different + * based on whether we are running with/without + * MMU enabled. + * + * For realms, we must force to use the shared physical + * alias with MMU disabled, to make sure the I/O can + * be emulated. + * When the MMU is turned ON, the mappings are created + * appropriately. + */ + if (mmu_enabled()) + return uart0_base; + return (u8 *)arm_shared_phys_alias((void *)uart0_base); +} + static void uart0_init(void) { /* @@ -81,9 +101,11 @@ void io_init(void) void puts(const char *s) { + volatile u8 *uart_base = get_uart_base(); + spin_lock(&uart_lock); while (*s) - writeb(*s++, uart0_base); + writeb(*s++, uart_base); spin_unlock(&uart_lock); } diff --git a/lib/arm64/asm/pgtable.h b/lib/arm64/asm/pgtable.h index 5b9f40b0..871c03e9 100644 --- a/lib/arm64/asm/pgtable.h +++ b/lib/arm64/asm/pgtable.h @@ -28,6 +28,11 @@ extern unsigned long prot_ns_shared; */ #define PTE_NS_SHARED (prot_ns_shared) +static inline unsigned long arm_shared_phys_alias(void *addr) +{ + return ((unsigned long)addr | PTE_NS_SHARED); +} + /* * Highest possible physical address supported. */ From patchwork Fri Jan 27 11:40:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13118611 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 00A69C54EAA for ; Fri, 27 Jan 2023 12:23:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=i8wLQA6QZztKwAj7OOLy5xN815qVP8zY36sHMDa+jO4=; b=3Zm9pZ60kG7N1Q wLpMzc1kZs2oXj4FrdNzvnTvOaLHEX4lQtsyvRcxfvapOjGA8Sbntzsdfr7yuFE5fHVdM2gcCGVQA CgHNL1GPJmdP0Va+sAPOqFNTtj1BAmYWx5MnWhgx1IqjFlHTINaKYa8OUpfB6j8+3yMts2WeHkNLa Y9f6akFgonuDLGbvdQMlTBzmx6bIbM73VrHjuqt631fUV7u6n+Zm8Bu4aH/5MQA9oysn5CscTyvRO rMZbX3mBa0pMkE+yEoE/Wnp/NHc6BUQqN2YWtYQ7lHzWi6tLDuTIYtyJ1fjPpPhzfKsufYfI3b4r/ NcZ/GlbdZp45R7rzrNzA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNjz-00EW8E-RJ; Fri, 27 Jan 2023 12:22:00 +0000 Received: from mail-am0eur02on2074.outbound.protection.outlook.com ([40.107.247.74] helo=EUR02-AM0-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN7j-00EDzZ-OS for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:42:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=m3PXBb4SSqTJtAHYbgMwbsFsilPhoJvLJat1+V5pGRk=; b=teCllaDYprHB57RNGMDs+MbVsedMgn2+Yw86C637bEdiObkB8PsfAWv+Y+XxPOLH4msvA/gJwPUq702toOWO1xcIZHPnX9Ep2ySWBmFkoYHHikDbtkO0/YgX+9ofJQmHikee+DPXXkc5JdrxMfzk4bxDsYUMbuR6KPzBJaU1dms= Received: from AM6PR08CA0043.eurprd08.prod.outlook.com (2603:10a6:20b:c0::31) by AS8PR08MB6456.eurprd08.prod.outlook.com (2603:10a6:20b:336::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23; Fri, 27 Jan 2023 11:42:13 +0000 Received: from AM7EUR03FT053.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:c0:cafe::88) by AM6PR08CA0043.outlook.office365.com (2603:10a6:20b:c0::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23 via Frontend Transport; Fri, 27 Jan 2023 11:42:13 +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 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM7EUR03FT053.mail.protection.outlook.com (100.127.140.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.22 via Frontend Transport; Fri, 27 Jan 2023 11:42:13 +0000 Received: ("Tessian outbound 0d7b2ab0f13d:v132"); Fri, 27 Jan 2023 11:42:13 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: f10d6ff2762418f7 X-CR-MTA-TID: 64aa7808 Received: from 4942fa1c6f02.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 92B6480C-80AA-44BC-AC6F-3CA257DF5AB0.1; Fri, 27 Jan 2023 11:42:05 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 4942fa1c6f02.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 27 Jan 2023 11:42:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SwOjveYkIk9iEBPUHRkXVu+3flM8sABzyumrJwn/UEhm2fy4ZgCY73hZMdbaGXA3vukJc112WnmJE/xb6iauiOgAdfDlE0J02SVSEc8jhJZtm+trwsBVIL6FWSXAojCnxaBbqoom2ZyeBc3TI3Ww1rd2ipknyBVRt2QifTNDKGAf1f1RU0A1y7jB87swNw1aiSpwKbYbciGXOKLErKahBGUkgVnt/kVmegW0zY3hJ+hwLfpJdbbHNnXQIXaeCIhi/vPEqS0vLoL/JafN920WoG6Qwl+XVWaDWiBmRWHUpNU3NxGAf9KfgNycr0w+9gQKvAND32W5g4rbsoPiE8rSfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=m3PXBb4SSqTJtAHYbgMwbsFsilPhoJvLJat1+V5pGRk=; b=WoTXprq/EWjq4tC+imzQgrFrp01cxfjYqESgLllb8yeOE3Tr1Tc1Qc2k/l/dUtvWeBS9A/x/ZreI88uGJKQ3z2Upml/voSOmjgGQdLByUFQ8WGjewqUOq5h8YvW7cKU6x216JqE1USezmvnUjsyV07red16I60MAZi+nyJ2ZjHdoJUvAu1hCAmZ//M0ts9lFuXsOIlfSmLpiwZxtqDQ94HeiJCdAjQLYfppxZQIuWH0pudLwU5zg//nTKBXC8l3j4xkBRnen1HjtOvVX8JCJWbzTKsG5SOKOYvqh6zcCu9u1DsN6zmWOtuvPlplb5MmOL3hMMYvBjNsuG2WkXsoqrw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=linux.dev smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=m3PXBb4SSqTJtAHYbgMwbsFsilPhoJvLJat1+V5pGRk=; b=teCllaDYprHB57RNGMDs+MbVsedMgn2+Yw86C637bEdiObkB8PsfAWv+Y+XxPOLH4msvA/gJwPUq702toOWO1xcIZHPnX9Ep2ySWBmFkoYHHikDbtkO0/YgX+9ofJQmHikee+DPXXkc5JdrxMfzk4bxDsYUMbuR6KPzBJaU1dms= Received: from AM5PR04CA0010.eurprd04.prod.outlook.com (2603:10a6:206:1::23) by VE1PR08MB5583.eurprd08.prod.outlook.com (2603:10a6:800:1ac::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33; Fri, 27 Jan 2023 11:42:03 +0000 Received: from AM7EUR03FT005.eop-EUR03.prod.protection.outlook.com (2603:10a6:206:1:cafe::45) by AM5PR04CA0010.outlook.office365.com (2603:10a6:206:1::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23 via Frontend Transport; Fri, 27 Jan 2023 11:42:03 +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 Received: from nebula.arm.com (40.67.248.234) by AM7EUR03FT005.mail.protection.outlook.com (100.127.140.218) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6043.25 via Frontend Transport; Fri, 27 Jan 2023 11:42:02 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) 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.16; Fri, 27 Jan 2023 11:42:01 +0000 Received: from e124191.cambridge.arm.com (10.1.197.45) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Fri, 27 Jan 2023 11:41:55 +0000 From: Joey Gouly To: Andrew Jones , , CC: , Alexandru Elisei , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Suzuki K Poulose , "Thomas Huth" , Will Deacon , Zenghui Yu , , , , Subject: [RFC kvm-unit-tests 08/27] arm: realm: Realm initialisation Date: Fri, 27 Jan 2023 11:40:49 +0000 Message-ID: <20230127114108.10025-9-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230127114108.10025-1-joey.gouly@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127114108.10025-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT005:EE_|VE1PR08MB5583:EE_|AM7EUR03FT053:EE_|AS8PR08MB6456:EE_ X-MS-Office365-Filtering-Correlation-Id: d7160db4-6661-492e-3250-08db005b8876 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: l1n7+XZjSyqfW/XOP8i0HXiuC0odLH+5j+ZTSyT9gGkaRekbTisuAFI2rf+E9S3uoxHXu39O2eDwNo/s9tyKbU3QlifTtTLRkOOUmGdDFG/SU/I/4sbm97AbqXWavs1s8WqOWEvo8FNEEM0FeYk7f5QjYjgjprHnS+WPIIhwfRaFx08Sxw16xGBSk3fowbrAF559a6tqdnsLVHkpXY9ylLFzm/XUc/7l5Xe1+gw8HFwK3t0hXpFnPokRwRKYZ6zaOkYH+Ip/BulhaizmSR6qDVJ+l4RVT08QsjR2DRS62T1eQ3KokqmYtQZ5hYOlDnXQIQ0/p02Zh4L5yrR+t0UtyUGvjHgWiGKyeKgOR+E95dmlxWLGeHIJvBIkIdGEVhGoGVW3L2koi/Cgb3FNgFLU8nGRVV6gFU5SE6n7M7zGxyytYYDEUvAdMzas/yezCLpXRaXoFLtj5HAl/ag1qKGr2oBg8zFSZuS470yPT320w1dyFZ71T9uGErO4dn2xHlkvZh6GzL1jTnPgSpriQ4wNRPrflbuFj/nWbJ8PFVWpZtF3suCj70j7OIcKKUlQhhNslcXd+07oBNQh7LvdbzAX+2f8wqWiG/ZODejxg9hz4UPHIVj1RaW6mafvBe206lnAAR8RPPmfv47gnCvtMn2XIzUgVcabcaV3v5jDPRXbVVw3rUcvXkxSLeR2iN6DcFUpUsdpI82wUYCCj+298bv5OyQ0wyWbmeNmCe93ySfTXkR7fVOMQ0ahsG1b2lO2eRWG 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:(13230025)(4636009)(346002)(376002)(136003)(396003)(39860400002)(451199018)(36840700001)(46966006)(40470700004)(81166007)(8676002)(36756003)(86362001)(82740400003)(40480700001)(44832011)(2906002)(426003)(4326008)(1076003)(6666004)(7416002)(40460700003)(83380400001)(186003)(41300700001)(26005)(8936002)(5660300002)(478600001)(336012)(70586007)(54906003)(316002)(82310400005)(70206006)(356005)(47076005)(36860700001)(2616005)(110136005)(7696005)(36900700001)(2101003);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5583 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT053.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 246d5100-1af4-47aa-93e9-08db005b8239 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: h/KGx8mmr707bpfnrfnyoGmvCI3D3GEU9Pj8mrOkbfKdvHY9i/VQsMOurESzVWG53OSFjPZRWhxwakQzsZbMQBa8FnKpclJmyrBHyJ8JE87+O6fW+TidBy/zvaAPR6UQVCf7T0FaRWq7XAaobqXRD7iQajIIA2/RqDw5Pn3eLEhlzQW+nNe+LJcNKo21VX1oybM+vGZpHEHbv4Ng/tB5BMW7WifC1bRpjcJB74TOsPnw8xChhfO35ai+KXyVmJ59+z28uSG0JPjf9zlWSCArWJkmN5BU11aanZCd+DnpOjFbP2ymkOGnCL2kIj7pqbQ8vsDOU2mSJN/Hl2bcR5XQpJPi2+PNocQ4VHj+SHzjnI2HPtUWbLvjvI1uhcNwsyeiNIg0vgRBHAuDUx852aGxlNbin9LxnnWIBzgK/jH5Nifn0WqZmSCk6z6AzNDfThDv/oRx9VfTyaQu96Uv6T2HcY/V04rjJ3a4i1pK0NpcnfA5PbL41GBCBeQsYjnd0J2bcU+owrb6q+Y/fwxgrw4WHadrWMqNLLZLa3CyeePga3q4jBDnUlbg800ud5o3nRE+0kcScWKOhSezcFJw21O0XxC0V4/oagtkeTN2q4FUQmz7IlSwQnOlZYHk7R1LMI+nM7hTyl8dNaPPkvA1fA/BEZTVPtvKo4VHrCboBxl+5ZAes9fsn5oe/9zVI+kffJDGCiOjyJAG3Cw+QNcvFQmowQ6hnsIoqXz2Hg+7a006fPw= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230025)(4636009)(136003)(376002)(39860400002)(396003)(346002)(451199018)(46966006)(40470700004)(36840700001)(41300700001)(8936002)(5660300002)(336012)(36860700001)(426003)(47076005)(40460700003)(83380400001)(40480700001)(82740400003)(316002)(110136005)(36756003)(86362001)(54906003)(82310400005)(7696005)(70586007)(70206006)(8676002)(186003)(4326008)(26005)(2616005)(1076003)(478600001)(81166007)(6666004)(107886003)(2906002)(44832011)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2023 11:42:13.3591 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d7160db4-6661-492e-3250-08db005b8876 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: AM7EUR03FT053.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6456 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034228_018284_F0730646 X-CRM114-Status: GOOD ( 16.42 ) 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 During the boot, run a check for the presence of RMM. If we are Realm, detect the Realm configuration using RSI and initialise the key parameters. Also expose a helper to indicate if this is running inside a Realm Co-developed-by: Suzuki K Poulose Signed-off-by: Suzuki K Poulose Signed-off-by: Joey Gouly --- arm/Makefile.arm64 | 1 + lib/arm/asm/rsi.h | 16 ++++++++++ lib/arm/setup.c | 3 ++ lib/arm64/asm/processor.h | 8 +++++ lib/arm64/asm/rsi.h | 36 +++++++++++++++++++++ lib/arm64/rsi.c | 67 +++++++++++++++++++++++++++++++++++++++ 6 files changed, 131 insertions(+) create mode 100644 lib/arm/asm/rsi.h create mode 100644 lib/arm64/asm/rsi.h create mode 100644 lib/arm64/rsi.c diff --git a/arm/Makefile.arm64 b/arm/Makefile.arm64 index 42e18e77..ab557f84 100644 --- a/arm/Makefile.arm64 +++ b/arm/Makefile.arm64 @@ -24,6 +24,7 @@ cstart.o = $(TEST_DIR)/cstart64.o cflatobjs += lib/arm64/processor.o cflatobjs += lib/arm64/spinlock.o cflatobjs += lib/arm64/gic-v3-its.o lib/arm64/gic-v3-its-cmd.o +cflatobjs += lib/arm64/rsi.o OBJDIRS += lib/arm64 diff --git a/lib/arm/asm/rsi.h b/lib/arm/asm/rsi.h new file mode 100644 index 00000000..d1f72c25 --- /dev/null +++ b/lib/arm/asm/rsi.h @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2022 Arm Limited. + * All rights reserved. + */ +#ifndef __ASMARM_RSI_H_ +#define __ASMARM_RSI_H_ + +#include + +static inline bool is_realm(void) +{ + return false; +} + +#endif /* __ASMARM_RSI_H_ */ diff --git a/lib/arm/setup.c b/lib/arm/setup.c index 65d98e97..36d4d826 100644 --- a/lib/arm/setup.c +++ b/lib/arm/setup.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -244,6 +245,8 @@ void setup(const void *fdt, phys_addr_t freemem_start) u32 fdt_size; int ret; + arm_rsi_init(); + assert(sizeof(long) == 8 || freemem_start < (3ul << 30)); freemem = (void *)(unsigned long)freemem_start; diff --git a/lib/arm64/asm/processor.h b/lib/arm64/asm/processor.h index 1c73ba32..320ebaef 100644 --- a/lib/arm64/asm/processor.h +++ b/lib/arm64/asm/processor.h @@ -114,6 +114,14 @@ static inline unsigned long get_id_aa64mmfr0_el1(void) #define ID_AA64MMFR0_TGRAN64_SUPPORTED 0x0 #define ID_AA64MMFR0_TGRAN16_SUPPORTED 0x1 +static inline unsigned long get_id_aa64pfr0_el1(void) +{ + return read_sysreg(id_aa64pfr0_el1); +} + +#define ID_AA64PFR0_EL1_EL3 (0xf << 12) +#define ID_AA64PFR0_EL1_EL3_NI (0x0 << 12) + static inline bool system_supports_granule(size_t granule) { u32 shift; diff --git a/lib/arm64/asm/rsi.h b/lib/arm64/asm/rsi.h new file mode 100644 index 00000000..8b9b91b2 --- /dev/null +++ b/lib/arm64/asm/rsi.h @@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2022 Arm Limited. + * All rights reserved. + */ +#ifndef __ASMARM64_RSI_H_ +#define __ASMARM64_RSI_H_ + +#include + +#include +#include +#include + +#define RSI_GRANULE_SIZE SZ_4K + +extern bool rsi_present; + +void arm_rsi_init(void); + +int rsi_invoke(unsigned int function_id, unsigned long arg0, + unsigned long arg1, unsigned long arg2, + unsigned long arg3, unsigned long arg4, + unsigned long arg5, unsigned long arg6, + unsigned long arg7, unsigned long arg8, + unsigned long arg9, unsigned long arg10, + struct smccc_result *result); + +int rsi_get_version(void); + +static inline bool is_realm(void) +{ + return rsi_present; +} + +#endif /* __ASMARM64_RSI_H_ */ diff --git a/lib/arm64/rsi.c b/lib/arm64/rsi.c new file mode 100644 index 00000000..23a4e963 --- /dev/null +++ b/lib/arm64/rsi.c @@ -0,0 +1,67 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2022 Arm Limited. + * All rights reserved. + */ +#include + +#include +#include +#include + +bool rsi_present; + +int rsi_invoke(unsigned int function_id, unsigned long arg0, + unsigned long arg1, unsigned long arg2, + unsigned long arg3, unsigned long arg4, + unsigned long arg5, unsigned long arg6, + unsigned long arg7, unsigned long arg8, + unsigned long arg9, unsigned long arg10, + struct smccc_result *result) +{ + return arm_smccc_smc(function_id, arg0, arg1, arg2, arg3, arg4, arg5, + arg6, arg7, arg8, arg9, arg10, result); +} + +struct rsi_realm_config __attribute__((aligned(RSI_GRANULE_SIZE))) config; + +static unsigned long rsi_get_realm_config(struct rsi_realm_config *cfg) +{ + struct smccc_result res; + + rsi_invoke(SMC_RSI_REALM_CONFIG, __virt_to_phys((unsigned long)cfg), + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, &res); + + return res.r0; +} + +int rsi_get_version(void) +{ + struct smccc_result res = {}; + int ret; + + if ((get_id_aa64pfr0_el1() & ID_AA64PFR0_EL1_EL3) == ID_AA64PFR0_EL1_EL3_NI) + return -1; + + ret = rsi_invoke(SMC_RSI_ABI_VERSION, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + &res); + if (ret) + return ret; + + return res.r0; +} + +void arm_rsi_init(void) +{ + if (rsi_get_version() != RSI_ABI_VERSION) + return; + + if (rsi_get_realm_config(&config)) + return; + + rsi_present = true; + + phys_mask_shift = (config.ipa_width - 1); + /* Set the upper bit of the IPA as the NS_SHARED pte attribute */ + prot_ns_shared = (1UL << phys_mask_shift); +} From patchwork Fri Jan 27 11:40:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13118613 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 7F844C54EAA for ; Fri, 27 Jan 2023 12:25:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Bu6xaOdJoFzlKT6hIpFitxWOMoGossRXdwFv/6hL7E4=; b=UGm0YQ5IMd5Pir tsI2b6fFxIJWyaFw6MVdx5udG5aA+uf1QRAZHeYBeblkrwcFAXI5Mav7rkDA25m+QVAMtwDE9prM+ hm+VexmRhzC7zkBRJSWWFHeJsjJtKyFmnIN1E+KUJO72ZHYez7ptiApmw0XFQ4vra5Q6TOllEdZtl YdpddqKi9Hhvo+L71rY3v+9/0Ou17MAlrFQTjPoXBLLkDMSmu3jD6nLBg+LbQklnM+1Sn0Ny09R24 9fWi9kIw0qAH5axXBJI5jFECKFVp1RNE7CLHa6TzqeI9Ta2v2L8xtuiR9AxRU0HygCACsX/tqziBs t9huAaPBv/9TsXCj9msQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNm5-00EWxv-B5; Fri, 27 Jan 2023 12:24:10 +0000 Received: from mail-vi1eur05on2059.outbound.protection.outlook.com ([40.107.21.59] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN7j-00EDzg-UH for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:42:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7LPirvCS090ii8x00q60vC8CmR1XvwhXOu0GKUUIIY0=; b=MNceCef5xhcEzMv0CP9yefRYmetyvnhJdaUwaBbgQ4DH/2wahnVWzrkyzpQDsCw1RXqYA9uMRSL6QqHX7wzl5GWE7cnfbrZiEmzpnVOUTv0mvBi9qO0IkZsMxmTy1LSexHAOf1Jh4JqhI3M7AKaa+YTsVp9V3KetY4YX5onLnGw= Received: from AS8P189CA0016.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:31f::7) by PAXPR08MB6608.eurprd08.prod.outlook.com (2603:10a6:102:150::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23; Fri, 27 Jan 2023 11:42:20 +0000 Received: from AM7EUR03FT056.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:31f:cafe::12) by AS8P189CA0016.outlook.office365.com (2603:10a6:20b:31f::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23 via Frontend Transport; Fri, 27 Jan 2023 11:42:20 +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 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM7EUR03FT056.mail.protection.outlook.com (100.127.140.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.22 via Frontend Transport; Fri, 27 Jan 2023 11:42:20 +0000 Received: ("Tessian outbound 43b0faad5a68:v132"); Fri, 27 Jan 2023 11:42:20 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 9bd9ecc9dc87ca10 X-CR-MTA-TID: 64aa7808 Received: from 3b00719e383c.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 3F85915E-32AB-4BCC-946B-18C3739F12DB.1; Fri, 27 Jan 2023 11:42:13 +0000 Received: from EUR03-AM7-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 3b00719e383c.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 27 Jan 2023 11:42:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HrAvJ0Bo6Nd6TvUrqElZBwAhjYSS09Ch+IatBKizTGWo3iMmLJche31ZuUg8LR3nTIIJJLj/igPVkU6NRI2alqITDgX6ECpcTM9GYfmxd5RQYOwDzTVQqWs7U8o0WRTrpz4jcYM55Bsf3mGei4fC1nWX2oHTQ/J8YLvnhy4gFviupnwU+uzQVeCuMqVG+zzx40Oj0QolGcOu6+BMAvOgNsmxYSzbsbdcNP1usWPbjb/K+g/heiLrznBggCCP43W2Cq0i2c37nFzQ/G0aiNOaHyZ3VWE6RI/nvgfVwPQM4TH5aOzZUCIf5qxaaisTm6yw7CzLEFXD2R7afsmfUM8+Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7LPirvCS090ii8x00q60vC8CmR1XvwhXOu0GKUUIIY0=; b=TCGoGqauAJNz1KM73ynZRh22GYMnAanTSEylvR4S6I9vMzaPMll8p1rTQGShmTByYIfpHXRmmZNeEcO7GyAYJU2a6wnMHSKrouzJ9x7Iliz+BRLH2DcITgHBqtjyDa9ImrhIZQODKfSWAKM1KlKPRvOVG5rKcVvSFv/+6r7pOQRwraPR1dkuVQFcm8+cOfOJnHuSvYqB86YbCBzIanYtToFRD1V99AtWL7+Al8UjZD2/wRezlWVFn9uTXvHUvSbjfMEl5xK2nRNXw6tc1eGDqJ9L4ooiA3tfVV3B/1Kx8Zxbv6XbGI5aiovTjXxR1+j1Iq4f8kB+5wsWPQ7wADgufw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=linux.dev smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7LPirvCS090ii8x00q60vC8CmR1XvwhXOu0GKUUIIY0=; b=MNceCef5xhcEzMv0CP9yefRYmetyvnhJdaUwaBbgQ4DH/2wahnVWzrkyzpQDsCw1RXqYA9uMRSL6QqHX7wzl5GWE7cnfbrZiEmzpnVOUTv0mvBi9qO0IkZsMxmTy1LSexHAOf1Jh4JqhI3M7AKaa+YTsVp9V3KetY4YX5onLnGw= Received: from AS9PR06CA0718.eurprd06.prod.outlook.com (2603:10a6:20b:49f::33) by DU0PR08MB9079.eurprd08.prod.outlook.com (2603:10a6:10:470::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.22; Fri, 27 Jan 2023 11:42:08 +0000 Received: from AM7EUR03FT048.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:49f:cafe::f8) by AS9PR06CA0718.outlook.office365.com (2603:10a6:20b:49f::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23 via Frontend Transport; Fri, 27 Jan 2023 11:42:08 +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 Received: from nebula.arm.com (40.67.248.234) by AM7EUR03FT048.mail.protection.outlook.com (100.127.140.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6043.23 via Frontend Transport; Fri, 27 Jan 2023 11:42:08 +0000 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.16; Fri, 27 Jan 2023 11:42:07 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) 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.16; Fri, 27 Jan 2023 11:42:06 +0000 Received: from e124191.cambridge.arm.com (10.1.197.45) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Fri, 27 Jan 2023 11:42:01 +0000 From: Joey Gouly To: Andrew Jones , , CC: , Alexandru Elisei , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Suzuki K Poulose , "Thomas Huth" , Will Deacon , Zenghui Yu , , , , Subject: [RFC kvm-unit-tests 09/27] arm: realm: Add support for changing the state of memory Date: Fri, 27 Jan 2023 11:40:50 +0000 Message-ID: <20230127114108.10025-10-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230127114108.10025-1-joey.gouly@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127114108.10025-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT048:EE_|DU0PR08MB9079:EE_|AM7EUR03FT056:EE_|PAXPR08MB6608:EE_ X-MS-Office365-Filtering-Correlation-Id: dfda2e87-4170-408b-e57e-08db005b8cbe 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: rheXZgf8s9vM0JR+2yCi7Tl5zJkej8a2aTYURTHqrXgT5cudKFEHmXNQuv0Jyd5KyOP8qfcb45HSVfrDz0RZVytOq+XFlmAI+Ynipl1YS9UcvUvZ40bDBmDlEEEfuyYbcaNXmvlwDNkCqsZXifivrT+AMgvkVn031kRF8N5vcUXUVxTI4Ak1CwRvWp86vjRlQw51CCkGjsrZAir0c0EQrRa8xcA4toNqwbwxsnYUnhCOwsoUUog5ae/Yfud70Hx6eickmijPR9yB/FFIYi8zC8cASeQy5qIAVWJepNRvhtJRSb8EuFoWLrrqM8bHZF2Mhsyyo0fvDs4m7/XWv+ltQCuwBWsK8G5PI/qPj/Rk9KwSdacUdgix0nhjje61kwnOb0612iEUi2gbYCSGRfuQVHrMVTtZ2lWgZjyGVV1y8yrX1a7AUuripHEPJ5+SzY6ZNEPoactivURJd6Nrl9po4uZ/Zpy2fvzvMvWuKZ8rSUnTGCSKPgxr2Ra7UAy12VsnKLcCHXKATTJZ48nITcIEof5p1H0tWzgW7u0ai1GhdXw2leGB0XLWmxhW09Apiw43SpoBJCvBd0RAu/vEbmeteD4MaSrNiSxx7Zt0J9UwHwHiXMixoT0but71Kph2euez2Wa9dzIFfa7Yro6DMetmczZ9GwkYY0RMhH+x/HK5Z6eWSznaXJDCnch94tEFUHUg2EN1nCpGVg8gLhvWolfBwXcSefl7p5K78RoSNDaWipgAqaHVTa3hIwmrSEl1/IqT 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:(13230025)(4636009)(346002)(39860400002)(376002)(396003)(136003)(451199018)(36840700001)(40470700004)(46966006)(2906002)(26005)(1076003)(41300700001)(186003)(110136005)(426003)(54906003)(47076005)(4326008)(83380400001)(70206006)(8676002)(70586007)(36860700001)(356005)(6666004)(316002)(86362001)(44832011)(82310400005)(40480700001)(40460700003)(82740400003)(81166007)(478600001)(7416002)(2616005)(336012)(8936002)(5660300002)(7696005)(36756003)(2101003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB9079 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT056.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: db2a54ca-f8cc-4e96-1ae6-08db005b85a3 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: M6nHsIpIvTkX0gQrTGrJYg2rRmdcp8higc9Ys6AKVROHrw/T9fyvw0hUG/SNiC9MSY64rIfp8nPBZmiSYxt03Rmr5AW90hkGJwgP38DbBj4iwCtdoOl88SZvcwFFOYMX4NNBoBMumH3k5Gi59cXUCouTgoSxzqf7j+7OxJeuvx+ByzIch/bRLmGXIfOCM8+kPd0TYCKTnZ3OJE2pYM5RcixES0Wxq3jNs2ZLNw5cM5odnWrI4dMhVZZ5QXuBH1yTNE23aw2W93dX2FBkCAasm3JjRTUAFFQ8L4zHh+kDHu+O/dXCQLTAl5XCmndY4OPKXKNoL0x/zbkW0C7AMksCXfHbfHKG1w5UcKlOxX4ZGbtKFzsQW6ZfMQA437ZQWIjol9MLbjnqQx3P0q6UUetNyF2pgmMgFjDWIUOpITYxQQeXtmeRlm5F+65PgUR0/XqyW1W563g9/sUYMfBNFmOgw32Ba2iBnbVrQbKxnUnO4hxXk1/pW2DsKvZRSHQFQG6gZmTuqIxEjfSPn0RfmC01Fc1b5eipYpvKuHzdzuCyZYoP4K/xksI2X7+PGopEz11JPDatU/Qn5odDYrjCQ6FwA59U+jFMo+sQEzaV2/j8bm50DSexFp2H6jDiHRbpE65CphMmUnAnQmpHqsdZAwUdEOlMDFw1pGVhZBnsMx2qPrtWv8xGRKZTNdVFprKKnFGxR9/7/uAirITd93Dg4ctkwGVQr1DaW6GrzQXPLumCmzs= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230025)(4636009)(396003)(376002)(39860400002)(346002)(136003)(451199018)(46966006)(36840700001)(40470700004)(1076003)(478600001)(186003)(26005)(4326008)(8676002)(107886003)(6666004)(70586007)(70206006)(7696005)(336012)(82310400005)(41300700001)(2616005)(426003)(47076005)(83380400001)(2906002)(86362001)(54906003)(110136005)(8936002)(81166007)(40460700003)(36756003)(36860700001)(82740400003)(44832011)(40480700001)(5660300002)(316002)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2023 11:42:20.5933 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dfda2e87-4170-408b-e57e-08db005b8cbe 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: AM7EUR03FT056.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6608 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034228_235844_64855858 X-CRM114-Status: GOOD ( 18.01 ) 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 For a Realm, the guest physical address (in reality the IPA/GPA of the VM) has an associated state (Realm IPA State, RIPAS) which is either of : RIPAS_RAM RIPAS_EMPTY The state of the physical address decides certain behaviors. e.g., any access to a RIPAS_EMPTY PA will generate a Synchronous External Abort back to the Realm, from the RMM. All "PA" that represents RAM for the Realm, must be set to RIPAS_RAM before an access is made. When the initial image (e.g., test, DTB) of a Realm is loaded, the hypervisor/VMM can transition the state of the loaded "area" to RIPAS_RAM. The rest of the "RAM" must be transitioned by the test payload before any access is made. Similarly, a Realm could set an "IPA" to RIPAS_EMPTY, when it is about to use the "unprotected" alias of the IPA. This is a hint for the host to reclaim the page from the protected "IPA. This patchs adds supporting helpers for setting the IPA state from Realm. These will be used later for the Realm. Co-developed-by: Suzuki K Poulose Signed-off-by: Suzuki K Poulose Signed-off-by: Joey Gouly --- lib/arm/mmu.c | 1 + lib/arm64/asm/rsi.h | 8 ++++++++ lib/arm64/rsi.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) diff --git a/lib/arm/mmu.c b/lib/arm/mmu.c index 6f1f42f5..2b5a7141 100644 --- a/lib/arm/mmu.c +++ b/lib/arm/mmu.c @@ -12,6 +12,7 @@ #include #include #include +#include #include "alloc_page.h" #include "vmalloc.h" diff --git a/lib/arm64/asm/rsi.h b/lib/arm64/asm/rsi.h index 8b9b91b2..c8179341 100644 --- a/lib/arm64/asm/rsi.h +++ b/lib/arm64/asm/rsi.h @@ -33,4 +33,12 @@ static inline bool is_realm(void) return rsi_present; } +enum ripas_t { + RIPAS_EMPTY, + RIPAS_RAM, +}; + +void arm_set_memory_protected(unsigned long va, size_t size); +void arm_set_memory_shared(unsigned long va, size_t size); + #endif /* __ASMARM64_RSI_H_ */ diff --git a/lib/arm64/rsi.c b/lib/arm64/rsi.c index 23a4e963..08c77889 100644 --- a/lib/arm64/rsi.c +++ b/lib/arm64/rsi.c @@ -65,3 +65,47 @@ void arm_rsi_init(void) /* Set the upper bit of the IPA as the NS_SHARED pte attribute */ prot_ns_shared = (1UL << phys_mask_shift); } + +static unsigned rsi_set_addr_range_state(unsigned long start, unsigned long size, + enum ripas_t state, unsigned long *top) +{ + struct smccc_result res; + + rsi_invoke(SMC_RSI_IPA_STATE_SET, start, size, state, 0, 0, 0, 0, 0, 0, 0, 0, &res); + *top = res.r1; + return res.r0; +} + +static void arm_set_memory_state(unsigned long start, + unsigned long size, + unsigned int ripas) +{ + int ret; + unsigned long end, top; + unsigned long old_start = start; + + if (!is_realm()) + return; + + start = ALIGN_DOWN(start, RSI_GRANULE_SIZE); + if (start != old_start) + size += old_start - start; + end = ALIGN(start + size, RSI_GRANULE_SIZE); + while (start != end) { + ret = rsi_set_addr_range_state(start, (end - start), + ripas, &top); + assert(!ret); + assert(top <= end); + start = top; + } +} + +void arm_set_memory_protected(unsigned long start, unsigned long size) +{ + arm_set_memory_state(start, size, RIPAS_RAM); +} + +void arm_set_memory_shared(unsigned long start, unsigned long size) +{ + arm_set_memory_state(start, size, RIPAS_EMPTY); +} From patchwork Fri Jan 27 11:40:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13118612 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 1189CC54EAA for ; Fri, 27 Jan 2023 12:24:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ria76qr5atf6DBe4Qyl8dr29MMQWnnXlBTkthmoE1ho=; b=TjXrCaNpR1/aMu /sDeLuMlP1NA3vzXDfAooP//mcSmO059Dnkh/gzrq07R4dT11gjnO2wbbxioRALnjmVKsWJpjpqUU 9LOVgNj+pBBXI26bF4u0Ojz2n/LvBVlQrrGWJzmGM+hcENnnxky5wLhXiSrVT+XOaSUi5qMtnkgnh +HGeiGRE7WlOK8o0NSJpbd46dIhofAFSwSLlVTDcXXojjVoMWcopx47mg8RYVU+hepBYLbdAgGYcM bjRyTIujTWdzmYTvQmjD8/9Z+440uhu2y5DyBiKDYgsUSIJVpu5PGBVRuYh3IBNYW9lhdAO2O79T9 Y/Q6CL00IVBKk1Bmh0Ww==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNkm-00EWRe-8B; Fri, 27 Jan 2023 12:22:48 +0000 Received: from mail-vi1eur05on2085.outbound.protection.outlook.com ([40.107.21.85] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN7j-00EDze-UH for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:42:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BKUc6k5BydLVdfAhCZDW2BV1A+Pf2tNjyrVVfOkNRBk=; b=SAvWSnN98f2hb9mw6rrD+Z8Q8+BgvgYk8FPgwqjl+d0IpFb2GFkQnh0bJraTYGz2Tv00EHHaJeOHV+MnhbCWsR3MXuXUVQuz75S3MmtAWbJJUJU3ML+Xx3lRRxcI8OQkPloDNjggRQt86Y66Xt+0o4br182JegpjmeuOlI/tUCQ= Received: from AS9PR04CA0031.eurprd04.prod.outlook.com (2603:10a6:20b:46a::10) by PAWPR08MB9830.eurprd08.prod.outlook.com (2603:10a6:102:2e2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23; Fri, 27 Jan 2023 11:42:22 +0000 Received: from AM7EUR03FT025.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:46a:cafe::34) by AS9PR04CA0031.outlook.office365.com (2603:10a6:20b:46a::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23 via Frontend Transport; Fri, 27 Jan 2023 11:42:22 +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 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM7EUR03FT025.mail.protection.outlook.com (100.127.140.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.22 via Frontend Transport; Fri, 27 Jan 2023 11:42:21 +0000 Received: ("Tessian outbound baf1b7a96f25:v132"); Fri, 27 Jan 2023 11:42:21 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 6c64ba3becf4f171 X-CR-MTA-TID: 64aa7808 Received: from b0a773cadefd.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 448B61F0-7F96-44A2-A403-35D6918DEF7C.1; Fri, 27 Jan 2023 11:42:14 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id b0a773cadefd.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 27 Jan 2023 11:42:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MhXKrKTOXLunmpbCtIdiL/niGVW2nmU9SPyzCWwQAFliHuFsRjS+7KX4mxb24cgljXUcdStWgSC2jIuKWLHPfZwZT0gSSIii/rXa0Ca7kSYED7BFFVXLCuLX+gaejOcFuhBqwd7p3HzlkSNmXckq9yzn0sGbn+8pw4EskrmJ+nckKBYpzmiL2TfMcYK+5NrX4aMaCr5Hoig3Aj9ehr2X0hxv9sJBMikHsK3ZxSsC6P6sdfqekyFHCY0CUloDEhYYLlYEqGlMB8H/HxGQrX6MAbKdVsHN/t8LSje/oy5RvaJP+qyhWHZPXLMI/Ffp9DF0exW/ZuZdCoNOHJMlQ1HIBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=BKUc6k5BydLVdfAhCZDW2BV1A+Pf2tNjyrVVfOkNRBk=; b=mC94RW0PfzLraKBdD/pO2kqjRt6y+f+EgeIm6VugklubWGFTfqPqxZKcBN01d+DXQ3QlDW01uo9vBl0n4IppfuxtfdjYWixru0DQVDz6TxNtWTUPsKuSmh7I2zL1sIQnv5P+8FAR8CW8/aYEIaHE0iw3EcI7i4puKr9ALYI0diYEm5ObOi+TEXtgRYEH7juyCyVvTY5HbvlxJqFkJ7SO/d9WJfHczVka9oEBOugZXI6cfUJ5VHETrKHs8IGuSkPrLJLHLMGJ45c84kaikMULnCtIJBHUTCeG3XtjzmfCDbSg59HY/RXs6rO+CWql8OTtpD5LZVR0zg5LLc1N6jLRTw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=linux.dev smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BKUc6k5BydLVdfAhCZDW2BV1A+Pf2tNjyrVVfOkNRBk=; b=SAvWSnN98f2hb9mw6rrD+Z8Q8+BgvgYk8FPgwqjl+d0IpFb2GFkQnh0bJraTYGz2Tv00EHHaJeOHV+MnhbCWsR3MXuXUVQuz75S3MmtAWbJJUJU3ML+Xx3lRRxcI8OQkPloDNjggRQt86Y66Xt+0o4br182JegpjmeuOlI/tUCQ= Received: from AS9PR0301CA0043.eurprd03.prod.outlook.com (2603:10a6:20b:469::35) by DU0PR08MB8422.eurprd08.prod.outlook.com (2603:10a6:10:406::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33; Fri, 27 Jan 2023 11:42:13 +0000 Received: from AM7EUR03FT029.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:469:cafe::6b) by AS9PR0301CA0043.outlook.office365.com (2603:10a6:20b:469::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.22 via Frontend Transport; Fri, 27 Jan 2023 11:42:13 +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 Received: from nebula.arm.com (40.67.248.234) by AM7EUR03FT029.mail.protection.outlook.com (100.127.140.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6043.22 via Frontend Transport; Fri, 27 Jan 2023 11:42:13 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) 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.16; Fri, 27 Jan 2023 11:42:12 +0000 Received: from e124191.cambridge.arm.com (10.1.197.45) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Fri, 27 Jan 2023 11:42:07 +0000 From: Joey Gouly To: Andrew Jones , , CC: , Alexandru Elisei , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Suzuki K Poulose , "Thomas Huth" , Will Deacon , Zenghui Yu , , , , Subject: [RFC kvm-unit-tests 10/27] arm: realm: Set RIPAS state for RAM Date: Fri, 27 Jan 2023 11:40:51 +0000 Message-ID: <20230127114108.10025-11-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230127114108.10025-1-joey.gouly@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127114108.10025-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT029:EE_|DU0PR08MB8422:EE_|AM7EUR03FT025:EE_|PAWPR08MB9830:EE_ X-MS-Office365-Filtering-Correlation-Id: c312bbe2-96ca-4157-54aa-08db005b8d59 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: hhtDTy6STJ9a9QEZL8zimAoI431SQb3ajffRVUwOzB2azBv+DpuOUmqM+RiuF3PS1oYf9egQTcmaOmeUGK/TsGedqJvL0rt0jf+mEy3HpHwoFV0OVsgkVsF/gdt6qfgcr5XW8FdU9CqNJpshXKN9VaKmHimY+WLgbM1SEmF1fhE3AYaPzofWgRyO4T+/4/kukYHyhpKkdZ9ImwfWL/+iCxEaYdR5YZPDKxWlZR1PY8etGHY1JEROMdeeSyu/2ESSK0NjuQSKYi3iYJyzcrV52y9gupsTIcD8HlIH0LL00cn7QRyPKzQltircLKMVmm5SAqMlJ1NMfE0H94w5ttFNEINA4h+WFsgi/zzLLgTnExUjyy+lFNR3ge4TMElHf/f1R1ex2zvWH3MSaC8qaWgb0LkFiYyV28a2b7SXnt57cuKHsfwdJrnfRGklWBuxeuheykeHwqa8o+tTXZlImScG6tZZI+7RY3TAsvb8t5qOzPL9WpNqBHPr9r6d3xhRCq67WSpGfXGprxgG7rLCa/sPz471SOvhs9FoUfE5VDW6X4N5fGNz6yW8kkBiaZgZlw35zkn7lx7ry422F+zSrfZBIb8x5rMY/3uXj+0x3r8X5CkNKLQT5/M7NfLY2nbdKXoKshS/fABOxxdWWAczM+BxuqZV8C6fkEu/1+8BThjHjJtP7vQ0k9bOaV0z08XukMzAbdy/lhJ1w3pZvBru4hqey0IC/HSFWasxtAntWH39sX6DKHswIOxYAaa/Z6ftsPCY 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:(13230025)(4636009)(136003)(396003)(376002)(346002)(39860400002)(451199018)(36840700001)(46966006)(40470700004)(7416002)(316002)(426003)(47076005)(82740400003)(336012)(40460700003)(6666004)(40480700001)(478600001)(82310400005)(70586007)(8676002)(186003)(54906003)(26005)(8936002)(1076003)(7696005)(2616005)(2906002)(41300700001)(36756003)(86362001)(5660300002)(81166007)(70206006)(4326008)(110136005)(36860700001)(356005)(44832011)(83380400001)(36900700001)(2101003);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8422 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT025.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 93c97a55-017d-4a7d-2a0c-08db005b888a X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5AmYDtOwghlm/n8iCq5069zkpAvz4zdTyDemMuLtIOHzfhg2ZjD3tdg7xJM+oTHv/3AU7CHhcrcmR83hBCNUnmdRtinWHMJ83rnA8f88+JnsTZsVTbrgqL5oP37XkupT7YZhZ0d/TrVk94udRYF0fhVPMUB+bzR/YBgVXxDe0mISMCeyra+4hWfpAybAy0os1oyISnTbCQyFnbpEjI9HlHgCGzJFXnTHw66QOFusD8NLa/TH2ZPMBc6BjXp6+mRhDRp2S7S06nzjK0CkKOF6K18h6ATWyLGOu3BjcBFXZjX1Lc7xno+MSeXWEq+N0qrN4zWLUJINHGQWLJd2XjWfGdC2a5U4IsR6P7+Xle/4gMZK23eswXRkeXGWRIHTAd0wpY//FlvwH2gLMix+RDC6XetoghQ+WfTJWkjeT0wh/HdZR3uV2Guy94LfrpG/J0/qAqLTuVGFymQ0FUx3IWBKjJEQVGL3y5szl4TC+GEQUry62zYsLz1Kh+T95gIzQgR1/6b8vK4tt4UYjn9SDCWSxc1Dskr/kbKnlkcAThb+RYRxg7zUqIUOtDXrCVuxe0hrQfov8hb9LCUzpCHhv1GBpp9Rg9FU1MLv8NbyUxWGCnywHXyuJzmZkuJExuxtU8dLWJRaZfjkl3MT7Ogwlyfr+rzU3XPho9WslnHtHCrUbh2t4/jlARYTRx/nOHIBWobuIZTczTwqe4mh2HB0PVQAJ+eFuqCGwjyYjStamR3Kq9I= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230025)(4636009)(346002)(376002)(39860400002)(396003)(136003)(451199018)(40470700004)(36840700001)(46966006)(83380400001)(336012)(36860700001)(36756003)(82310400005)(40460700003)(82740400003)(47076005)(426003)(110136005)(5660300002)(54906003)(316002)(2616005)(86362001)(40480700001)(186003)(81166007)(26005)(107886003)(7696005)(478600001)(6666004)(2906002)(8936002)(44832011)(8676002)(70206006)(4326008)(70586007)(1076003)(41300700001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2023 11:42:21.5897 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c312bbe2-96ca-4157-54aa-08db005b8d59 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: AM7EUR03FT025.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR08MB9830 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034228_042393_197CB601 X-CRM114-Status: GOOD ( 15.42 ) 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 From: Suzuki K Poulose A Realm must ensure that the "RAM" region is set to RIPAS_RAM, before any access is made. This patch makes sure that all memory blocks are marked as RIPAS_RAM. Also, before we relocate the "FDT" and "initrd", make sure the target location is marked too. This happens before we parse the memory blocks. It is OK to do this operation on a given IPA multiple times. So, we don't exclude the inital image areas from the "target" list. Also, this operation doesn't require the host to commit physical memory to back the IPAs yet. It can be done on demand via fault handling. Signed-off-by: Suzuki K Poulose Signed-off-by: Joey Gouly --- lib/arm/setup.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/arm/setup.c b/lib/arm/setup.c index 36d4d826..7b3dc0b8 100644 --- a/lib/arm/setup.c +++ b/lib/arm/setup.c @@ -181,6 +181,7 @@ static void mem_init(phys_addr_t freemem_start) while (r && r->end != mem.end) r = mem_region_find(r->end); assert(r); + arm_set_memory_protected(r->start, r->end - r->start); /* Ensure our selected freemem range is somewhere in our full range */ assert(freemem_start >= mem.start && freemem->end <= mem.end); @@ -252,6 +253,11 @@ void setup(const void *fdt, phys_addr_t freemem_start) /* Move the FDT to the base of free memory */ fdt_size = fdt_totalsize(fdt); + /* + * Before we touch the memory @freemem, make sure it + * is set to protected for Realms. + */ + arm_set_memory_protected((unsigned long)freemem, fdt_size); ret = fdt_move(fdt, freemem, fdt_size); assert(ret == 0); ret = dt_init(freemem); @@ -263,6 +269,7 @@ void setup(const void *fdt, phys_addr_t freemem_start) assert(ret == 0 || ret == -FDT_ERR_NOTFOUND); if (ret == 0) { initrd = freemem; + arm_set_memory_protected((unsigned long)initrd, initrd_size); memmove(initrd, tmp, initrd_size); freemem += initrd_size; } From patchwork Fri Jan 27 11:40:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13118614 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 CB6C2C54EAA for ; Fri, 27 Jan 2023 12:26:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/rIdcEKjn+gbgN4aV7nJobRP9QWqiJ8ZTYnIunQZB3Q=; b=2ILqiGw9u2hzq2 jdqDl0JqPHEPp7yW/gPqzFTKkH/ljEMHjugNRhslFLPpJTQJ3QV50r1G5g+Dy8yH9+v8sZx3ARFu8 4xIT0O3w2FN8268hqSK0Aen14pOs5KlqVTpTlEh5/9wFvKln1suASyYIsbLNacBJn/Z9SV1JQqgno mpI7NqdwJAHuozlMXlVLqAbA2rdV/Raw/Ki+isi6r57If9/JdZTuBzBDA7pWrK68UZR19ssR2tea1 nlnY0zDzGMmHUtsklNuPcmHsNe5R8K8/48yFZllue4XeuDshm6KXxWc6shO4rp5nCTuM+xkO+EWZz XmpaPgCigNqXPejI8G4A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNmp-00EXGn-MG; Fri, 27 Jan 2023 12:24:59 +0000 Received: from mail-ve1eur01on2081.outbound.protection.outlook.com ([40.107.14.81] helo=EUR01-VE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN7s-00EE3T-1k for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:42:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dcIXZq6ds6bP9ip4JE/j1qNlUvY5S7B0ErdLpFp4kKY=; b=gcTKPFAnKsEzwokxUHMc7fNUJCIcgW/URrg/UKVZsWeyNHbWhCudWBNVZ/JLpzyKlwMAX/58J8FxcAbp2gdElfUesI+GR0TjFy0oL3wOrpglhLY8pTTI/GoW35eCvRtDvUdWwqAelD61kVpWGsp3JPWp8hY658Pbvh4ldppoETw= Received: from DU2P251CA0001.EURP251.PROD.OUTLOOK.COM (2603:10a6:10:230::12) by AS8PR08MB6181.eurprd08.prod.outlook.com (2603:10a6:20b:29a::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23; Fri, 27 Jan 2023 11:42:30 +0000 Received: from DBAEUR03FT024.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:230:cafe::fb) by DU2P251CA0001.outlook.office365.com (2603:10a6:10:230::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23 via Frontend Transport; Fri, 27 Jan 2023 11:42:30 +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 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT024.mail.protection.outlook.com (100.127.142.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.21 via Frontend Transport; Fri, 27 Jan 2023 11:42:30 +0000 Received: ("Tessian outbound 6e565e48ed4a:v132"); Fri, 27 Jan 2023 11:42:30 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 3bb6f51fcd59317f X-CR-MTA-TID: 64aa7808 Received: from 0919c10c4366.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 528B6F7E-9C34-4A82-84C8-D670B97DE6B8.1; Fri, 27 Jan 2023 11:42:23 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 0919c10c4366.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 27 Jan 2023 11:42:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nKyVCRI1ZmXQagPfhGGMg2dWZH4SDmnP8zoBmgWf7OY/Cj+1Ea2dFoBS6LqJjxZ/m3j+OXK+wndZQJMTPk3cMzJc6ADbdlpJcqZZDJvufm61bkVI6JDQ5j2KsnVsHF2pL7HSS89M0C0+ohmAidvy9HQ6AS226rV+lcqRntgJx+SYpAoY8YHlPtHE67YgnD/7wFTYRIgXc8hKOUNM/wvE7roFPz4bEU9vz8lh+UrZkPHnd08p2g7tpYPS+xrWsyD3PHjElmB4e22pUwbt0uuc1QSHCADYrGGIK7HHN+sQ8Q9Ya2C6sNuIjmtZd+qf0dIDobRCJpomYI1h/OuxVCXvKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=dcIXZq6ds6bP9ip4JE/j1qNlUvY5S7B0ErdLpFp4kKY=; b=cnRLBERUTO/fWuXiWXqYZ+bhjKK8+d/3L/7Atb/EtLYdxVRfCh6s3wBdoIOyRmVhcSSCoeK/Cvk9jrsOPRExbPabICzJfdIlOehNuTy3vfPDcu2a/sU0NM9cjB4h0pbbkfwEQ7UuCdqkTeZsopRD2Ui+1gR4Gfd94sxMSNkL+0nAnJ5CZiu1T1gD7xS05x0djkJHwvRgu5Qoyf7g4OEUbxaqnnLlXVEJfej8SuyUvXwsC5Zg1gc1cAwi8PFGZtKwJresJg7yRiqtdCFTnYgnNZWxMLUr96PSb0QCgcBV6HkRRza694Z8O6Nts7Tol+YokzJdyOZscN0grVqUr5cn2w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=linux.dev smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dcIXZq6ds6bP9ip4JE/j1qNlUvY5S7B0ErdLpFp4kKY=; b=gcTKPFAnKsEzwokxUHMc7fNUJCIcgW/URrg/UKVZsWeyNHbWhCudWBNVZ/JLpzyKlwMAX/58J8FxcAbp2gdElfUesI+GR0TjFy0oL3wOrpglhLY8pTTI/GoW35eCvRtDvUdWwqAelD61kVpWGsp3JPWp8hY658Pbvh4ldppoETw= Received: from DBBPR09CA0008.eurprd09.prod.outlook.com (2603:10a6:10:c0::20) by PA4PR08MB6269.eurprd08.prod.outlook.com (2603:10a6:102:ed::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23; Fri, 27 Jan 2023 11:42:19 +0000 Received: from DBAEUR03FT012.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:c0:cafe::22) by DBBPR09CA0008.outlook.office365.com (2603:10a6:10:c0::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23 via Frontend Transport; Fri, 27 Jan 2023 11:42:19 +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 Received: from nebula.arm.com (40.67.248.234) by DBAEUR03FT012.mail.protection.outlook.com (100.127.142.126) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6043.21 via Frontend Transport; Fri, 27 Jan 2023 11:42:18 +0000 Received: from AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Fri, 27 Jan 2023 11:42:18 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) 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.16; Fri, 27 Jan 2023 11:42:18 +0000 Received: from e124191.cambridge.arm.com (10.1.197.45) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Fri, 27 Jan 2023 11:42:12 +0000 From: Joey Gouly To: Andrew Jones , , CC: , Alexandru Elisei , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Suzuki K Poulose , "Thomas Huth" , Will Deacon , Zenghui Yu , , , , Subject: [RFC kvm-unit-tests 11/27] arm: realm: Early memory setup Date: Fri, 27 Jan 2023 11:40:52 +0000 Message-ID: <20230127114108.10025-12-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230127114108.10025-1-joey.gouly@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127114108.10025-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT012:EE_|PA4PR08MB6269:EE_|DBAEUR03FT024:EE_|AS8PR08MB6181:EE_ X-MS-Office365-Filtering-Correlation-Id: 4a369fbf-a804-4227-7134-08db005b929d 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: WPtP+nScV3xsIsPYWNRpZ4Pmab10S9T5ZdEkXtMAiSUnJV6QXnlsaDENYHBGS96TIPhC7N3sEh5FgvLKL2qK3oUcx2eF9ub0+GBsLbQ3R3fRLALP4pKHAqeDWOQYFHItN1gp6nwWSgh4lCY6SvnjhH+qQutAEvDnwTfk8T/YtwTB8WlrP07C36IouBdPxFwwADUkUH9SOxf1V/kHlTxjBde3rAr70HXiHPldGUmTnI4bMgGaEJp7wGY6pHXlJFxAy9bqIcmsS2kZcy2YKd4vJYUjFC0iPK9KzdxyJdMpTTc3lUaS6vL6XnXYs4vE0ODp4RMb0ePlfr/0cP1S55qHBkkWeE1JlTEs4hmILGMRlet8Gk9Jqw/refcmEnjYtzHS9VG6c/c43Bh9Oavw7veconh6mtSSgHXgGVRmrwHSN1IhnLUF8EQa7TZ+f9mfDS2jHttjwh7URT2v4IbI4njTQ6i8VHc+XLAoRKwHHpr8z6RnWabHbJApwxIypjniBwhjK9iLdeKSFvdmW3AYRHRRUku3VsIRrqjZMPk4UX3bzf8HVwffXwjgJ4D0z/N6ai9zwV4IDfPtpHzRt6jZgjL9lbV8SS+lS9N6x+Ph5WsTpHb1tKDKl22w8fbLxqA2LdZYQynMHuRpuyoXqDxbap4HK2A3Iuil8N9ur1g4F0cySLZH1EL7kpslKSC4gT4X6skYxXBSWJ6x5rGtk8rE1DAE13S78Mx0U7uMjzaxEhXDn0gPLPl+LNacMsl5/i5hIpXI 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:(13230025)(4636009)(396003)(376002)(39860400002)(136003)(346002)(451199018)(36840700001)(40470700004)(46966006)(478600001)(44832011)(40460700003)(36756003)(70586007)(4326008)(70206006)(83380400001)(36860700001)(54906003)(82740400003)(110136005)(8676002)(316002)(1076003)(186003)(26005)(7696005)(6666004)(7416002)(5660300002)(47076005)(82310400005)(81166007)(426003)(356005)(2616005)(336012)(86362001)(41300700001)(40480700001)(8936002)(2906002)(2101003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB6269 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT024.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: f797dcb8-444f-4884-b7c7-08db005b8bbe X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dHm6HybqRRhj/ySoZ6+b+Al6pa2X9iAutDn9NPJZo/TVVyx8+IF1/2aRUNBFIVmbcaBLJQF8GsHvXcAdtWiiuJQDsDHBPvi6FIS1wRBx47Pv1FOzxrb2uDlag133M06a8AZ/iX5iF9lK9B0zLr7yupMnj5BkoXpuhaX4bX2oh9wFT2WIOlDePx17j4NQcgKPH0gnO1QtpVQ7YlnLF1ElU+kjLwIurjVjTSxlz5vEBrS7JmV2lS3Ey56lWT9gEAPRgEjtOz2LZWR2qC8TEdywepCwtZjXkW2sutCKm7hLGY4GWw1M0+KLoPTXqVDcHLAF/gkQrFFIgr52QU/dOGGr2wsyDP1+BccxIwMobmrdoiFPVNykUFuV28wVwlZq9VUwkf9/19Mhnr6Jcsk+TD3gpdy+PiGD1NDg+9YNkX9w/ZCYPFLFMMfksmzT7wzuZ95Ap4tXqxzK59KpU+DG3LP2C4cqGdJX/vNQC5X5of+hk3wGufH6J1ZI4g7U4+s5ao4h+9APtfQ4PvUR/BdNX5kAxPaw63wNmAbzcQgvUe3BnQmcUFsA3eusoL8VvnaNOJMCjtxi9uNeStz43OIuMx5MtKzpwVKEmw23dtPWlgldfDM66f+c2RYmGP5GyjAIqDIzmJ1vquZS5kroyFeSa//uQWNiDLCmgqkhWtp5PkZ7jjX65H690gZp8Fcin1yxd6b6O2AWOlHGlbKJ6Hs+gDlRTs/M1ET+kjoeSxdI/d2DeOM= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230025)(4636009)(376002)(396003)(136003)(39860400002)(346002)(451199018)(40470700004)(36840700001)(46966006)(36756003)(40460700003)(7696005)(54906003)(316002)(1076003)(110136005)(6666004)(107886003)(5660300002)(2906002)(44832011)(70206006)(70586007)(8676002)(4326008)(8936002)(478600001)(41300700001)(26005)(82740400003)(36860700001)(81166007)(86362001)(40480700001)(2616005)(83380400001)(426003)(336012)(186003)(47076005)(82310400005)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2023 11:42:30.4872 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4a369fbf-a804-4227-7134-08db005b929d 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: DBAEUR03FT024.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6181 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034236_153167_7012AF03 X-CRM114-Status: GOOD ( 15.81 ) 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 From: Suzuki K Poulose A Realm must mark areas of memory as RIPAS_RAM before an access is made. The binary image is loaded by the VMM and thus the area is converted. However, the file image may not cover tail portion of the "memory" image (e.g, BSS, stack etc.). Convert the area touched by the early boot code to RAM before the access is made in early assembly code. Once, we land in the C code, we take care of converting the entire RAM region to RIPAS_RAM. Please note that this operation doesn't require the host to commit memory to the Realm. Signed-off-by: Suzuki K Poulose Co-developed-by: Jean-Philippe Brucker Signed-off-by: Jean-Philippe Brucker Co-developed-by: Joey Gouly Signed-off-by: Joey Gouly --- arm/cstart64.S | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/arm/cstart64.S b/arm/cstart64.S index b689b132..b0861594 100644 --- a/arm/cstart64.S +++ b/arm/cstart64.S @@ -14,6 +14,7 @@ #include #include #include +#include .macro zero_range, tmp1, tmp2 9998: cmp \tmp1, \tmp2 @@ -61,6 +62,7 @@ start: b 1b 1: + bl __early_mem_setup /* zero BSS */ adrp x4, bss add x4, x4, :lo12:bss @@ -170,6 +172,76 @@ arm_smccc_hvc: arm_smccc_smc: do_smccc_call smc +__early_mem_setup: + /* Preserve x0 - x3 */ + mov x5, x0 + mov x6, x1 + mov x7, x2 + mov x8, x3 + + /* + * Check for EL3, otherwise an SMC instruction + * will cause an UNDEFINED exception. + */ + mrs x9, ID_AA64PFR0_EL1 + lsr x9, x9, #12 + and x9, x9, 0b11 + cbnz x9, 1f + ret + +1: + /* + * Are we a realm? Request the RSI ABI version. + * If KVM is catching SMCs, it returns an error in x0 (~0UL) + */ + ldr x0, =SMC_RSI_ABI_VERSION + smc #0 + + ldr x1, =RSI_ABI_VERSION + cmp x0, x1 + bne 3f + + /* + * For realms, we must mark area from bss + * to the end of stack as memory before it is + * accessed, as they are not populated as part + * of the initial image. As such we can run + * this unconditionally irrespective of whether + * we are a normal VM or Realm. + * + * x1 = bss_start. + */ + adrp x1, bss + + /* x9 = (end of stack - bss_start) */ + adrp x9, (stacktop + PAGE_SIZE) +2: + /* calculate the size as (end - start) */ + sub x2, x9, x1 + + /* x3 = RIPAS_RAM */ + mov x3, #1 + + /* x0 = SMC_RSI_IPA_STATE_SET */ + movz x0, :abs_g2_s:SMC_RSI_IPA_STATE_SET + movk x0, :abs_g1_nc:SMC_RSI_IPA_STATE_SET + movk x0, :abs_g0_nc:SMC_RSI_IPA_STATE_SET + + /* Run the RSI request */ + smc #0 + + /* halt if there is an error */ + cbnz x0, halt + + cmp x1, x9 + bne 2b +3: + mov x3, x8 + mov x2, x7 + mov x1, x6 + mov x0, x5 + ret + get_mmu_off: adrp x0, auxinfo ldr x0, [x0, :lo12:auxinfo + 8] From patchwork Fri Jan 27 11:40:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13118616 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 754A1C54EAA for ; Fri, 27 Jan 2023 12:28:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=gMvk+k/PFhzTy1s0Sh8+fenLFXCW9hu3GYy/mfsTLqQ=; b=bXAqqX5J2TvQA1 x0n07bOjo1rwtxlolvo5oIlko4N4BdArUwXgQL5ZzDFk2cDIGjUR58VzgfyEMr6F+UZvdfyWzR6eV mlFruHhHp079k9LrTvO3lp+YAomoD+8yAbgNlhES07EMNO/7HSFb7h2ZqunSH3p8P3Cy2+/5Fao/H +xYNhCunNizkQPGgM6NCMvyw+gIwT470hGCmWOc6lpU7cJ0vTmIiKUk4lyzdlmHK+qkiMx5A/2XMG 01fyiZn8bRenjtenpgKk0fJztvtZEHTl2fl0NWiadP9mZpG0cCn3yfgvilBZbpi1WIo1MP9rShaN5 HgKFPmXp+MewT0izROkg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNoc-00EXvT-40; Fri, 27 Jan 2023 12:26:46 +0000 Received: from mail-vi1eur05on20631.outbound.protection.outlook.com ([2a01:111:f400:7d00::631] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN8B-00EEE5-98 for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:42:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jBnCN7QdJ8CYRLAqVvlj5JNGftuZbnrdU6WdPVMigKs=; b=knpPzsPz7n9YQw1GOhwwpl0pfhjsJo8wcsjObJRt+swLP6QkNS4mOqTfz1Ef6zrybR00mzl1Vbludz+aa2MlQGAw5zTqh3Pqwt2gojEHWHH54aCAmobhw9Yhk8otUWkVn//lT57+12p1duRNI7VodJdImvIfyKFy52RxZR/1nkY= Received: from AM6PR10CA0076.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::17) by DB9PR08MB6441.eurprd08.prod.outlook.com (2603:10a6:10:252::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23; Fri, 27 Jan 2023 11:42:34 +0000 Received: from AM7EUR03FT054.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:8c:cafe::d5) by AM6PR10CA0076.outlook.office365.com (2603:10a6:209:8c::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23 via Frontend Transport; Fri, 27 Jan 2023 11:42:34 +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 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM7EUR03FT054.mail.protection.outlook.com (100.127.140.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.22 via Frontend Transport; Fri, 27 Jan 2023 11:42:34 +0000 Received: ("Tessian outbound 8038f0863a52:v132"); Fri, 27 Jan 2023 11:42:34 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 989407ff5cb2e6bc X-CR-MTA-TID: 64aa7808 Received: from 665dd25750ca.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 4420A9C3-87BC-4116-98FE-BA2B14E1F1AF.1; Fri, 27 Jan 2023 11:42:27 +0000 Received: from EUR01-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 665dd25750ca.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 27 Jan 2023 11:42:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Nv7LIYB2Q253DlqNaBPN04dNmrXUuAlmJAEQEScytcbXm3FAnRzBUm8rJbugP3AUGXky5VFdjdg310U+rY+gLsPhwX7yIb5BLM+2bAlnByWzPUfy+mj0G/WOIx78wHxPTcLh/GWNcc5AYsvMAjftzSD2uNHgycYAFLUlB6oEjnCOBTW9zSIg2oQ58o7J64+KBGqmrTHMwrccZu5eOvItkzceUKu8SJptz+nveoWFmHoBV9svTkuA69XBgBkyTJehmmFutfM1dlFAiF3d/9D9QK1sp0fSoMPYB95KRAE7ljTpkGMiJb146FGbcHVUP/ZVm8XTFzm6d7rIGPapLGXcXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jBnCN7QdJ8CYRLAqVvlj5JNGftuZbnrdU6WdPVMigKs=; b=Yl+XtsYF3lv8GyMHbSBb+UmW3TCDVO8lzdV3cx1kRmbpYewnN/W+mQ2nN26eoAye+LzEio6I9Xz0yTUe5SWvq65cHvuh95O8HXi/+EHlKvW6JUdLuGeIMp7fn6fK8qdSs1ar60W/CmT6jZgwylHmTKbGKy6yvMePc3Yr+/wZLUlCpp4qKr0emJ+L7O+Zg7qxJXNie/QbGWdvFGM4O6Lp+QbZlHDHgpiC9/msMi8qlBlvSRNjLUwv0P7PQeyIDhLraJoXzMQx+NzHrYE5BPFAwyIyjmNJU3p6EG46BlhtqA9VG5eFPdmrIBvLlZbrd0bJHO20g1brz6864mpIFT+rgw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=linux.dev smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jBnCN7QdJ8CYRLAqVvlj5JNGftuZbnrdU6WdPVMigKs=; b=knpPzsPz7n9YQw1GOhwwpl0pfhjsJo8wcsjObJRt+swLP6QkNS4mOqTfz1Ef6zrybR00mzl1Vbludz+aa2MlQGAw5zTqh3Pqwt2gojEHWHH54aCAmobhw9Yhk8otUWkVn//lT57+12p1duRNI7VodJdImvIfyKFy52RxZR/1nkY= Received: from AS9PR05CA0139.eurprd05.prod.outlook.com (2603:10a6:20b:497::31) by DU0PR08MB8186.eurprd08.prod.outlook.com (2603:10a6:10:3ed::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.22; Fri, 27 Jan 2023 11:42:25 +0000 Received: from AM7EUR03FT035.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:497:cafe::d5) by AS9PR05CA0139.outlook.office365.com (2603:10a6:20b:497::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23 via Frontend Transport; Fri, 27 Jan 2023 11:42:25 +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 Received: from nebula.arm.com (40.67.248.234) by AM7EUR03FT035.mail.protection.outlook.com (100.127.141.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6043.21 via Frontend Transport; Fri, 27 Jan 2023 11:42:25 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) 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.16; Fri, 27 Jan 2023 11:42:23 +0000 Received: from e124191.cambridge.arm.com (10.1.197.45) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Fri, 27 Jan 2023 11:42:18 +0000 From: Joey Gouly To: Andrew Jones , , CC: , Alexandru Elisei , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Suzuki K Poulose , "Thomas Huth" , Will Deacon , Zenghui Yu , , , , Subject: [RFC kvm-unit-tests 12/27] arm: realm: Add RSI version test Date: Fri, 27 Jan 2023 11:40:53 +0000 Message-ID: <20230127114108.10025-13-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230127114108.10025-1-joey.gouly@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127114108.10025-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT035:EE_|DU0PR08MB8186:EE_|AM7EUR03FT054:EE_|DB9PR08MB6441:EE_ X-MS-Office365-Filtering-Correlation-Id: 326c2275-7e59-4678-f1ce-08db005b94fb 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: i3s6LwEfWeEBxbNWkoNA4XkHRLRr9m+ioxOaYmnSXfL8p1gjmiPg8dXZ6zipI9g7McSOHvpzd/GoiTX8abKjjrLcsWK9kguA/gHQ43JsWRrBdTm3pXRUNeAC2r1pxYKCVmXyu5U7GpG3RaVG9y/XVKn3gSYsWTEnoz4mK2WXRECtoq9qyaoDldgwuFydMQD5z2BumxRA2qrDJ6u4WdInffULbejT0NjpZ1dkvsc9YAodIRCDOJCVNCn8uKowMykDFrEd5cOirpiW1mZRxRQipi6KxXPRJuuvTIf9LqHWRi7YCJPgaaQsxrwpmR9lqV/3P17E+eLysJwQS5KFFEB5jHRnqh0ArXSUu53qjpo24YU2ZYHnvntmxdRnd6uhoF/L8Osjq1liIPuZqbNtXI46SYVMl1yoEO2HVMJx7iktTcoTqxCuFWDFB157HHjRz5EGLAu0uD6P2h29bdLpRwiXW8M4J1mr2HVPKOBs7qnzqXMWttXgTVsKNkw3cQP7T/1vaF8CxqkRLehBcFjYeapGQEJ2Wuqaj30AdGyTMUDiC3zRtQs1ft/iEiusrEi2qRaxAfd0a7JAAlX/KdjEziPy5MIAgrRSKerOJMp5wxnWxEuSOwyQHz/VHFIlDFdgieS/g4pDDrk67Km51Y1T/D2numYI6onQzU8Lok69OCPcuP07EQgYbKXgug346uGtoFo2sisyBrHMRh0tT29zyzR4+i5bqH0P8X1SlKnn6gBkrlOOzAx2fDvsxbcdCrndhqPA 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:(13230025)(4636009)(396003)(376002)(39860400002)(136003)(346002)(451199018)(40470700004)(46966006)(36840700001)(2906002)(44832011)(7416002)(5660300002)(8936002)(47076005)(426003)(41300700001)(36860700001)(26005)(336012)(478600001)(2616005)(6666004)(186003)(1076003)(82740400003)(83380400001)(70206006)(40460700003)(81166007)(7696005)(86362001)(40480700001)(356005)(4326008)(70586007)(36756003)(82310400005)(8676002)(54906003)(316002)(110136005)(2101003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8186 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT054.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 77adec84-efc2-4db8-853e-08db005b8f81 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: S6xqoLjAsUHy0CBbnSC7U+3CXFbeuTIax6a+Fsz/K1X2TSqhJgYtu3biZcUFNTqqWPAqeihDGPiXJNSzcPqNV6Lt5g+tguX5a3sblu7uDMo01oXtb8BvemxjvUsIeIbu0AONcrWZjvU6PN5U+Xk8ayfH7Q6iI4M5MFPhYNSWRAnqxdHIws2E/djoKZpoan65VCC3xBML2n3WaCSeguLp2rcfTuTPWGFm72pfeScyht5yTpc72T/E6RpoA2BfQPxZxerXKN3Txk+3TuTPjFXqXnUPiijogobNj8n2ek2ETxxe4wjmiAwO2yrBIzaAcDJl9+AOUgazUvVbqGse2WwAyqD6peO0uuqG1Ewz8eDDz7t2djgi++td/FD2VHuSCDB62s0KLl48eBB4TtArkJ10jHCEZbnzPtLV1zhpE8z7BynK+Z1HHynfQFTRCX8aJFBeDRWwBZmyx43DwX7B6jQSDXTYmil5TrqAuaOQWkUwbhaxe2hOoSXFFlUoUfn7sjrlRonTqu267z6eS9Wc0flimRuYrXdD/DFZTmGln0KEEPpAPeaBI5CnxQk1wTTJmOi06m0BwSwYBIjWbE91Z5lL+B25DmZ2KeLzLtTh/8gEIOoxPDIi2CLSOQXYmmAhEqBo11V/NJuy+KkQHSTf4xtnsQLOrrnAcve9OODZXjYTXdJftGwWXxyXI8qD6qzLJbkt7lrA6HiuoIyJaXa+zhK2VVyQoG9VtfEXGjkgXfsXBYU= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230025)(4636009)(136003)(396003)(346002)(376002)(39860400002)(451199018)(46966006)(36840700001)(40470700004)(4326008)(8676002)(70586007)(5660300002)(70206006)(316002)(426003)(82740400003)(81166007)(40480700001)(41300700001)(8936002)(86362001)(336012)(82310400005)(54906003)(40460700003)(2616005)(36860700001)(47076005)(83380400001)(110136005)(36756003)(44832011)(6666004)(107886003)(478600001)(7696005)(26005)(2906002)(186003)(1076003)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2023 11:42:34.3995 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 326c2275-7e59-4678-f1ce-08db005b94fb 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: AM7EUR03FT054.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB6441 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034255_384501_6399AB1A X-CRM114-Status: GOOD ( 15.25 ) 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 Add basic test for checking the RSI version command. Signed-off-by: Joey Gouly --- arm/Makefile.arm64 | 1 + arm/realm-rsi.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++ arm/unittests.cfg | 7 +++++++ 3 files changed, 57 insertions(+) create mode 100644 arm/realm-rsi.c diff --git a/arm/Makefile.arm64 b/arm/Makefile.arm64 index ab557f84..eed77d3a 100644 --- a/arm/Makefile.arm64 +++ b/arm/Makefile.arm64 @@ -33,6 +33,7 @@ tests = $(TEST_DIR)/timer.flat tests += $(TEST_DIR)/micro-bench.flat tests += $(TEST_DIR)/cache.flat tests += $(TEST_DIR)/debug.flat +tests += $(TEST_DIR)/realm-rsi.flat include $(SRCDIR)/$(TEST_DIR)/Makefile.common diff --git a/arm/realm-rsi.c b/arm/realm-rsi.c new file mode 100644 index 00000000..d793f305 --- /dev/null +++ b/arm/realm-rsi.c @@ -0,0 +1,49 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2022 Arm Limited. + * All rights reserved. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static void rsi_test_version(void) +{ + int version; + + report_prefix_push("version"); + + version = rsi_get_version(); + if (version < 0) { + report(false, "SMC_RSI_ABI_VERSION failed (%d)", version); + return; + } + + report(version == RSI_ABI_VERSION, "RSI ABI version %u.%u (expected: %u.%u)", + RSI_ABI_VERSION_GET_MAJOR(version), + RSI_ABI_VERSION_GET_MINOR(version), + RSI_ABI_VERSION_GET_MAJOR(RSI_ABI_VERSION), + RSI_ABI_VERSION_GET_MINOR(RSI_ABI_VERSION)); + report_prefix_pop(); +} + +int main(int argc, char **argv) +{ + report_prefix_push("rsi"); + + if (!is_realm()) { + report_skip("Not a realm, skipping tests"); + goto exit; + } + + rsi_test_version(); +exit: + return report_summary(); +} diff --git a/arm/unittests.cfg b/arm/unittests.cfg index 5e67b558..ce1b5ad9 100644 --- a/arm/unittests.cfg +++ b/arm/unittests.cfg @@ -275,3 +275,10 @@ file = debug.flat arch = arm64 extra_params = -append 'ss-migration' groups = debug migration + +# Realm RSI ABI test +[realm-rsi] +file = realm-rsi.flat +groups = nodefault realms +accel = kvm +arch = arm64 From patchwork Fri Jan 27 11:40:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13118615 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 17689C61DA4 for ; Fri, 27 Jan 2023 12:27:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=IB4UUz1nIUmP/ZAnZkWZXvQQOyQrAxo08z+n9w7uFzw=; b=hdYVSi66/w/4RA velkT2rs1iOG1Dc6gY9P666e1IDH6+vPOev1pEpceMtOs7sZNLIcdrWDUh9RjhPNknlNIkPR1N5lm KjNZi9SZoDYyWu7p+V7aR+OQxxbmRVIzGrb7zv0O/+yD/PJg6a9o6SNnXk4xXNd3b4+n64+Y+oT1f LRi+Ynqsaqa7VipU1oaM5fFzhR9K2NkDujuVmAacMPclUqKg7t8vdwibHv6+1tzZdnlnH+Qwkx/J7 q7QBWsslej/LsaOPutyierCBK5cBbGJP6gELCTyA4/ZVHPv0QkoVRIZ//s6+2Lu3GN3cuoHMuDUbe NxgERrS1dYYVNgkZobyQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNnr-00EXdl-2c; Fri, 27 Jan 2023 12:26:00 +0000 Received: from mail-he1eur04on2050.outbound.protection.outlook.com ([40.107.7.50] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN83-00EE9d-O3 for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:42:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=F5Ov8UacraSFcK4tBbryQ4GhcjU0UFGydGtdRDc/yk8=; b=H1mbAO0JWyIuRp45Odg3qfVfwOnblw/CCrAC+s3Ds+QRtOUN2BERE0aBVozwV1qxwpSIyy7mSd4lRQM0yngu2LmN9RmJRmtYW38kIjL04Myy/HlUDFOwy4HgQ/opcuu+nb3wDVnUMUXL6fnSieeSRXaBvLS8SC5mOiIFEpMTPIM= Received: from DB6PR07CA0173.eurprd07.prod.outlook.com (2603:10a6:6:43::27) by AM9PR08MB6644.eurprd08.prod.outlook.com (2603:10a6:20b:30e::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23; Fri, 27 Jan 2023 11:42:41 +0000 Received: from DBAEUR03FT043.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:43:cafe::99) by DB6PR07CA0173.outlook.office365.com (2603:10a6:6:43::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.21 via Frontend Transport; Fri, 27 Jan 2023 11:42:41 +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 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT043.mail.protection.outlook.com (100.127.143.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.21 via Frontend Transport; Fri, 27 Jan 2023 11:42:41 +0000 Received: ("Tessian outbound 6e565e48ed4a:v132"); Fri, 27 Jan 2023 11:42:41 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 777ec3250e38b21b X-CR-MTA-TID: 64aa7808 Received: from df16ff2c3f36.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 525DFB33-F18D-4234-B437-F18678B6C84F.1; Fri, 27 Jan 2023 11:42:34 +0000 Received: from EUR02-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id df16ff2c3f36.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 27 Jan 2023 11:42:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Uo5lSDVOx3t7Y8y8msRL73p01q83AHzaBILaGaO51ydjjhWvC/vD2KxUaTxL304UzM98kgG8FjatzoBuzZCyG17ZlidG3a3+Djq9n4Y7w+LNzTHF3vE43RNn0OhELZiUopnOLD74kpHmV4DYOIwb32u/G2rEfhFd9/u9pN+u3lH+NQhExn5rX235otvNUh4K0qpVdlsfWOnudLOa9LF0lr1Z3vrzHIn68uPTbFKAglC7hZKVCvimJTSN/0lQ0fYqstVhf1enJ5Ab5fRrqZer/ClQOjZLLQ6e718SNga7Uc2fs1gQV3fVJ/II7gJDDUJlLhbTF24kKplNfD8+m7yoKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=F5Ov8UacraSFcK4tBbryQ4GhcjU0UFGydGtdRDc/yk8=; b=BOJ/SjvJLzoNmhokB2jIHzhBXHnP5Tqo2H0LaAjkCzcTVOMnSWTzDVP/yOOZCyFjQ+tXxurNgXfg0Kl2q/kzkO5CfiYKYI8OS+Gx/yL8JHm5H4XDu8oDhzwv9e/CYvBiF7kmcgoHYrZ4p+/+hyHD36xUGBNFr5sU6uCdDJS60d9NORpGOaEls6U1sxiAmZf3HiBFokin9fmpH8dgt99mN9ive1ehPBu/Zx2vyGCzo/M/BEfc/eitUCN9xFBwLXm6HGWnZzdLqeCKxJ6RnLeQUBH/ZIZiQWNItcHmtQuQDHrkhzVtbx8tbm3JAUTFlBeIG/88i2oA+9p8QL0y52kJGA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=linux.dev smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=F5Ov8UacraSFcK4tBbryQ4GhcjU0UFGydGtdRDc/yk8=; b=H1mbAO0JWyIuRp45Odg3qfVfwOnblw/CCrAC+s3Ds+QRtOUN2BERE0aBVozwV1qxwpSIyy7mSd4lRQM0yngu2LmN9RmJRmtYW38kIjL04Myy/HlUDFOwy4HgQ/opcuu+nb3wDVnUMUXL6fnSieeSRXaBvLS8SC5mOiIFEpMTPIM= Received: from AS8P189CA0016.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:31f::7) by DU0PR08MB7567.eurprd08.prod.outlook.com (2603:10a6:10:317::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33; Fri, 27 Jan 2023 11:42:30 +0000 Received: from AM7EUR03FT056.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:31f:cafe::ab) by AS8P189CA0016.outlook.office365.com (2603:10a6:20b:31f::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23 via Frontend Transport; Fri, 27 Jan 2023 11:42:30 +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 Received: from nebula.arm.com (40.67.248.234) by AM7EUR03FT056.mail.protection.outlook.com (100.127.140.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6043.22 via Frontend Transport; Fri, 27 Jan 2023 11:42:30 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) 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.16; Fri, 27 Jan 2023 11:42:29 +0000 Received: from e124191.cambridge.arm.com (10.1.197.45) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Fri, 27 Jan 2023 11:42:24 +0000 From: Joey Gouly To: Andrew Jones , , CC: , Alexandru Elisei , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Suzuki K Poulose , "Thomas Huth" , Will Deacon , Zenghui Yu , , , , Subject: [RFC kvm-unit-tests 13/27] arm: selftest: realm: skip pabt test when running in a realm Date: Fri, 27 Jan 2023 11:40:54 +0000 Message-ID: <20230127114108.10025-14-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230127114108.10025-1-joey.gouly@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127114108.10025-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT056:EE_|DU0PR08MB7567:EE_|DBAEUR03FT043:EE_|AM9PR08MB6644:EE_ X-MS-Office365-Filtering-Correlation-Id: 04ddb0ac-0244-4561-878f-08db005b994d 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: GM+2rLl8SvWoCrMdjKGsxxMJjukxumKihhfsqUwk2q/dogQIvCbwcId3KUu92gsTFnipgdSAG2Gr6u6moEcm1PzPShkshQUjeV1aDak0AfBHUDOVOgROWpKGd9NzunRTWai9Ayqk9ya6qABdtnjMIxfvLF3lSlbMkIf20cSVfMArM5+/BhRvQSfcCsodcxVuieNDAkWQGcoCwoN7q8CsyEbFq8OvLlcFQi4618CD6si/llK0Evq9OhgsbsPjXOQwHZrhUsN9AxRIUMsZWwjd7ZaDPo0g9ppDESHcHi+IBPeukjvNScPfcQ1zROSJY8le1FZuhlBmGzl8P2qcssy7MHelBBD1w76p8i7XjWPhf83dsheRpWFeWmA9iXRq3wS5dxEpHoMDTExYyYvmiwEfmwAXffqEO0utPRnDEyYvZGJM+eKBbW5DkmQwNroWbRcM1f9PWBdGhfRXKgobc98qrBPcr0ZVl7PDjzP1ggf31qiol45RnZua8+47chk2rKgLcStgTPEKuiSqwo4dcag9wKNBDlsVfa0R9unD2KGpzQrOGwSsWiMSpQXbPsE8ak8WuSe/gnvXZUcVfrzRC1x1LCcNEt2t9LTI6DNgj4KRrKIKEhhz3e+S3Kh9KkLfcBVBbgXEI7maMvnel2oFGcC3t8xUtbkTfSEiG5sqWgTNpZNSh10htU0r6EmNZUoohNqDfebb30P4kor05r0TuKOm3DJTuvemodMAWJakULA//Y50n6eHQjcl/9d6t0gfu87V 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:(13230025)(4636009)(39860400002)(376002)(346002)(396003)(136003)(451199018)(46966006)(36840700001)(40470700004)(186003)(8936002)(4326008)(70586007)(5660300002)(70206006)(8676002)(2616005)(316002)(81166007)(426003)(40480700001)(41300700001)(110136005)(36860700001)(7696005)(1076003)(6666004)(356005)(2906002)(82310400005)(44832011)(4744005)(40460700003)(82740400003)(36756003)(7416002)(47076005)(478600001)(336012)(86362001)(54906003)(26005)(36900700001)(2101003);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB7567 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT043.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 34a0317f-0b2c-4df5-e67e-08db005b9290 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3KzrF1aJD0zRVLAV5OGkNssCdO4z/5S6uHC6+iy8RubPBZ5fqDcFOC7Wm9K/avJP4rNVbZzkL8x1aCjTwklYDj6ZJwkkbQyXNC/LckM+x0INVBTiRxgaxxwYjpLQ1toCQSE+92IAW/0X/v/35L8ANYih0Ya7f1RwbdwlV0Uc6Fl7v5HfI8wDW1+S7jh6eMwBZJZFPGfr5eHo27QI7mRpZ8Xpfg4xHkrrU5BpnoXGpZYW9xbNLjcHsAvCYr3utwbjtrOhFA56lYS3urog5tfpVon10vbVk7V6/yfowrw5yXR5edKZpaEuhiwQsxaeTpHeOelffwEx7F9Klocv6Q3zOZHRroHhExEEBf4u2ZxxjzauUCGpV72mnFexG3nIFiil+v3FVPh3Xw43GzVQAewnc4uKuKGZRHw8yFY3SPA57Bb25DvXgRg60h6oWz8MGpcPbtSMt3aDvoRPbMiAMJ/PqtJtpw040FOblug3iFiGNVaDw6X3DmS0a7kzIwIwhRnEJ6BARog4v0BPCqBeyE3x6hxKM6FIs7SF/CGNLNJ9imCha2HNqIVGd/tviCF1xUhAqi17uYUUPGdH0V7b8ROVZpK8E051EHlubbTdwYvrONxo6OIssScwOVna7weSaJL7CLCZ2BoZec0IbWtZCC9OoSk1YeELGAB132XcvLsaZ2IlUpNHyYwxeJPgWfLMuKwzVKV+p24wNyHb9ul/1nCQHB/dMCmCDnTWzipkS9WqvX0= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230025)(4636009)(136003)(346002)(376002)(39860400002)(396003)(451199018)(40470700004)(46966006)(36840700001)(2906002)(44832011)(4744005)(426003)(336012)(36860700001)(8936002)(41300700001)(5660300002)(478600001)(2616005)(26005)(186003)(8676002)(107886003)(1076003)(6666004)(4326008)(7696005)(86362001)(81166007)(82740400003)(40480700001)(47076005)(40460700003)(70586007)(110136005)(36756003)(54906003)(316002)(70206006)(82310400005)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2023 11:42:41.6294 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 04ddb0ac-0244-4561-878f-08db005b994d 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: DBAEUR03FT043.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR08MB6644 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034247_889931_428E8DF7 X-CRM114-Status: GOOD ( 11.40 ) 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 From: Alexandru Elisei The realm manager treats instruction aborts as fatal errors, skip this test. Signed-off-by: Alexandru Elisei Signed-off-by: Joey Gouly --- arm/selftest.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arm/selftest.c b/arm/selftest.c index 6f825add..174f2ebc 100644 --- a/arm/selftest.c +++ b/arm/selftest.c @@ -18,6 +18,7 @@ #include #include #include +#include static cpumask_t ready, valid; @@ -392,11 +393,17 @@ static void check_vectors(void *arg __unused) user_psci_system_off); #endif } else { + if (is_realm()) { + report_skip("pabt test not supported in a realm"); + goto out; + } + if (!check_pabt_init()) report_skip("Couldn't guess an invalid physical address"); else report(check_pabt(), "pabt"); } +out: exit(report_summary()); } From patchwork Fri Jan 27 11:40:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13118629 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 9EE90C38142 for ; Fri, 27 Jan 2023 12:31: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: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=74B5EALP09aHTcdvpqByPX751EQUGqt9OdtJx39sRXA=; b=xQ23Mmce7oH7ac ukMhUcRe+Tupdy+d1JN7IbWtsnYguDRkUkFD0GxpYrqJ01BxV0RKA+WOOtk/Iyp0I6ITvstb8EPJE fJoPupRjztOb9DZi7QC2rKnCRwqj7L5CfpSwH1AJwmJVSgHWLAcu6sEAtlG5P1alACw1Fp3c5k96/ slMZSGRzk5WjysMlzm0SGN+1fdKM9as2djujhP9ykBb7bJyCLD8mxKx9jACWJ22vXkBrsqvJxoTcu KAX7o0z9bVMp+FZ0D9QTmzukU2R02GU7cGEQVWF0003QYU2R4w5/KzziPFZqIFh4c5yzCN/f1+e4q 6FhsnNVZ2zreCrMRLuaw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNrj-00EYxV-TI; Fri, 27 Jan 2023 12:30:03 +0000 Received: from mail-am6eur05on2070.outbound.protection.outlook.com ([40.107.22.70] helo=EUR05-AM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN8W-00EEOE-GE for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:43:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=x8JZG4jpM76HS5UgQpwVl4pSBZ5biDY9z3RHHccl+24=; b=eEm99mno32dYqI3hpPf2PrxE6B8TAhBUiPK2lrWFp2YfFFHG4JJWMQlumDw+ctLtbDM1kwQ+yTlpZLhjV3qpyIhSuqw+m19dVa3hL8UnzY4W6pS0d+Pic5ZdhpOojgbUpjkAfzE3o5zpmIgn6jfdq7DgLPSOhtKRWP1SKft/ug8= Received: from DB6PR0202CA0036.eurprd02.prod.outlook.com (2603:10a6:4:a5::22) by GV2PR08MB8486.eurprd08.prod.outlook.com (2603:10a6:150:bc::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23; Fri, 27 Jan 2023 11:42:48 +0000 Received: from DBAEUR03FT007.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:a5:cafe::e1) by DB6PR0202CA0036.outlook.office365.com (2603:10a6:4:a5::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.34 via Frontend Transport; Fri, 27 Jan 2023 11:42:48 +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 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT007.mail.protection.outlook.com (100.127.142.161) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.21 via Frontend Transport; Fri, 27 Jan 2023 11:42:48 +0000 Received: ("Tessian outbound baf1b7a96f25:v132"); Fri, 27 Jan 2023 11:42:48 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 80bc510a8692540b X-CR-MTA-TID: 64aa7808 Received: from 1241152e4df0.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id D608B248-C25F-4634-B0B6-0C794EB6F09D.1; Fri, 27 Jan 2023 11:42:41 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 1241152e4df0.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 27 Jan 2023 11:42:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WzHrXoU49HA4o+nc9qVkOVVzKPf0hiuPWeIgf0uC4dec4sWBwobCfZGf0Fa0XwgvFoA5Im4DP9GKbIj75f/gHmXSmUQ7JANAt5iZaNIWcy1yaV8xGlq9ccuk6K0jqIfeCcL1qg8fum3/TloB1rDZtlkEGG+yfK9llgvCLNuKfA+aJPHLr5R02zsl2kf5sCnX4EUYp2OaCpEfFSPRrpYI6nt+GoHMvoPosLqFOVJ5aas6WIE35tIRv2Jc9WM18cJJfhSOfMJsrYE81ulNNIB9ISWQLCVUIAXI6cQUc32UghBc/XJI2G47wYeyEr2Ovv+aKEnesSjOTZ5VbddGf5kCPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=x8JZG4jpM76HS5UgQpwVl4pSBZ5biDY9z3RHHccl+24=; b=UImYHWiroexKQOwiUHvF8LkBFze1K+PYBHF9LCBra1rYwh6Bvt/kQjux6ShQKjcF75NYX7cHvLakrO1asYF+OScVFa1nhh4Rgn8kD8nDPLCNSZjMhjGK6K1RT9qsFR409FbBUBkwyTjy2WrDuDFUHhHQC7JTYaF/1k1KHUgWIwZzw73x2gPNvyw4uYQRN0jItLng0vBBvkh//u4uSRnUEYMtHn6xON6DNCSwAr+Mly/OOzhyhJ6F19XbHP/mpMQOKN/IvI/y7rt/rElKKJ1aqBrZHPSiCslTx/ZGlT86Rwb7NGy0JnIWqMfasxuXGNgziXu1RROI2cR7JL7dg+tZ3w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=linux.dev smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=x8JZG4jpM76HS5UgQpwVl4pSBZ5biDY9z3RHHccl+24=; b=eEm99mno32dYqI3hpPf2PrxE6B8TAhBUiPK2lrWFp2YfFFHG4JJWMQlumDw+ctLtbDM1kwQ+yTlpZLhjV3qpyIhSuqw+m19dVa3hL8UnzY4W6pS0d+Pic5ZdhpOojgbUpjkAfzE3o5zpmIgn6jfdq7DgLPSOhtKRWP1SKft/ug8= Received: from AS9PR06CA0513.eurprd06.prod.outlook.com (2603:10a6:20b:49d::8) by GV1PR08MB8692.eurprd08.prod.outlook.com (2603:10a6:150:86::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.22; Fri, 27 Jan 2023 11:42:37 +0000 Received: from AM7EUR03FT013.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:49d:cafe::63) by AS9PR06CA0513.outlook.office365.com (2603:10a6:20b:49d::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.22 via Frontend Transport; Fri, 27 Jan 2023 11:42:36 +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 Received: from nebula.arm.com (40.67.248.234) by AM7EUR03FT013.mail.protection.outlook.com (100.127.140.191) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6043.22 via Frontend Transport; Fri, 27 Jan 2023 11:42:36 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) 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.16; Fri, 27 Jan 2023 11:42:35 +0000 Received: from e124191.cambridge.arm.com (10.1.197.45) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Fri, 27 Jan 2023 11:42:29 +0000 From: Joey Gouly To: Andrew Jones , , CC: , Alexandru Elisei , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Suzuki K Poulose , "Thomas Huth" , Will Deacon , Zenghui Yu , , , , , Gareth Stockwell Subject: [RFC kvm-unit-tests 14/27] arm: realm: add hvc and RSI_HOST_CALL tests Date: Fri, 27 Jan 2023 11:40:55 +0000 Message-ID: <20230127114108.10025-15-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230127114108.10025-1-joey.gouly@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127114108.10025-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT013:EE_|GV1PR08MB8692:EE_|DBAEUR03FT007:EE_|GV2PR08MB8486:EE_ X-MS-Office365-Filtering-Correlation-Id: f96b66b9-bb92-4bd2-81bc-08db005b9d79 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: LrrhC1LRwd7d9J67bWM/6pEwNPN1mwgg7HTt7Mo2eV8JUZkNJDd3VURcxYbCKSoikmjeJj17pAk93tFC6SG2+ujK0pEDUVGg32kNxMusiXfnV+fN11isNC6/oRiTZ+4FhqTTLzc0TsmpPMCIlJVWKrn4mbbmnhXTY2yVepWoPrWh5SqzZ95gzh9mRpBcGuXxuTvgKnw9CJLTRVyaxqiq5CdYfSm2TeDjfUPDjpNxwtOge0qe8QtxYVL/q9w8PMPCQ+ey3SKoenlgrxfNShpXmJzGeIAbjZGVgRMx44+o94XYxkcSr0E2Ob0qgHlFz0OWH6xWCp0New1nnjDqXk52dYiO+4mR+OYiHDQQILCjsV7nb0RxWmFF4pyhfzg8QYkNycXXvfsOfhV9UFbKQsM15v8oGBI+0v35xyrmy8+GRna1dqrcJiJpUnvqPedla7iaLb84XaAaJzEtAlP2sd43rCYS1yR+6zL/mKh6iia+X1v1cV/pTpsYNmUC4FXCKy7LyYRi/QUmr3ZpXTOwmEd3I2PkyQ73OhR15KPrbDYUZDGe0FsYIlapBJQpBEAwqD3MPf9QuDHsR4pl2S87yx4d8cTneNtYtSlCaCl+X9m4OUINkv4xj8qmY8vvGFTxxokM5137+UhjoxkAnklc4qJeLMri2tH5Tb563GNEihseyZ883m6lgt0FcanyynnMn/D9uWLQi94jJQcMzpYwW2btJOnU5n9+3bWCzKbGlPykQn0MOKX8hDbX0btTjhON3XSS 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:(13230025)(4636009)(396003)(136003)(39860400002)(346002)(376002)(451199018)(46966006)(40470700004)(36840700001)(5660300002)(70206006)(7416002)(8936002)(44832011)(2906002)(41300700001)(4326008)(70586007)(8676002)(6666004)(82310400005)(316002)(54906003)(110136005)(186003)(26005)(36756003)(7696005)(1076003)(478600001)(2616005)(336012)(40460700003)(81166007)(83380400001)(47076005)(426003)(36860700001)(40480700001)(82740400003)(86362001)(356005)(36900700001)(2101003);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB8692 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT007.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 55ea7516-98d0-44f5-ab2c-08db005b966c X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nWDxrow5hXDm2fU2pREtZzt7Vm3N+IdQkxOJ75U01MvFz8BkexDwg6LROY074x63VqNQtt80QSz4O4IcMkzerbbnIhYZ9B3J7ayKozmZIOsoB/e5m5Bxe1oQSsM4MURZsMdRec94lyUeAjwi4hhou2gDLl2Y9wjhuprishfjQTDNQbXn2tu07dpQKKB+/YVga8ya/yd+PQfKc9U/RWDkyU6tUMAPVVJgpgLmzNRGbWSptLIE3mOdozAo+rd7L3paeXkfULcolVV27IgnnMPzyjOeLcaVqXwvaD2iFQ91Z5fFAoteU7CVqn/Z4xdYQK2CTll+a1ZjCeCptEWD6OTdck/WmIpYp+XnhwtDFAP4h3Eio1aKHddd3PX0VN1RRcO5nrLDOM4tjNnr7UvVoHJl++XBWr4lPGIzidd8EyRHzovmYR5SUMgpbgy8nf6VRxo5VrSyeeh4uP1UCQ1IPHYYy24UTgpL9uWYudBrF0WT+W9+ZQbsUp18p53BbbM3cC87gYIk5+FrYb6zcG19QncBTjfsmRyouS+wwBKF3q+hCwVHlOcHENo9A62AMp0zP1/5On/OtB6Mr69oD/H2p3OxZYG33lObwHIAABgSaynTsWQ32r4wpyF+w0OlOb9Tz3HypVADacuOKsF/SVcYlgVEmjtjzfP9CktMNDA8f+090i650UIQNdI0dmMuuxIpfRcKEKHSqTJAsqXC6ksoYqZTueNUpml+EHEVF0g1SqkL0Gc= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230025)(4636009)(376002)(346002)(136003)(39860400002)(396003)(451199018)(40470700004)(36840700001)(46966006)(8676002)(4326008)(26005)(44832011)(186003)(1076003)(316002)(40460700003)(5660300002)(82740400003)(36860700001)(41300700001)(86362001)(40480700001)(82310400005)(81166007)(8936002)(47076005)(54906003)(83380400001)(36756003)(2616005)(426003)(70586007)(110136005)(70206006)(478600001)(7696005)(336012)(2906002)(6666004)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2023 11:42:48.7067 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f96b66b9-bb92-4bd2-81bc-08db005b9d79 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: DBAEUR03FT007.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR08MB8486 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034316_771987_2BB4E21E X-CRM114-Status: GOOD ( 16.17 ) 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 From: Gareth Stockwell Test that a HVC instruction in a Realm is turned into an undefined exception. Test that RSI_HOST_CALL passes through to the Hypervisor. Signed-off-by: Gareth Stockwell Signed-off-by: Suzuki K Poulose Signed-off-by: Joey Gouly --- arm/realm-rsi.c | 110 +++++++++++++++++++++++++++++++++++++++++++++- arm/unittests.cfg | 15 +++++++ 2 files changed, 124 insertions(+), 1 deletion(-) diff --git a/arm/realm-rsi.c b/arm/realm-rsi.c index d793f305..8a7e9622 100644 --- a/arm/realm-rsi.c +++ b/arm/realm-rsi.c @@ -14,6 +14,96 @@ #include #include +#define FID_SMCCC_VERSION 0x80000000 +#define FID_INVALID 0xc5000041 + +#define SMCCC_VERSION_1_1 0x10001 +#define SMCCC_SUCCESS 0 +#define SMCCC_NOT_SUPPORTED -1 + +static bool unknown_taken; + +static void unknown_handler(struct pt_regs *regs, unsigned int esr) +{ + report_info("unknown_handler: esr=0x%x", esr); + unknown_taken = true; +} + +static void hvc_call(unsigned int fid) +{ + struct smccc_result res; + + unknown_taken = false; + arm_smccc_hvc(fid, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, &res); + + if (unknown_taken) { + report(true, "FID=0x%x caused Unknown exception", fid); + } else { + report(false, "FID=0x%x did not cause Unknown exception", fid); + report_info("x0: 0x%lx", res.r0); + report_info("x1: 0x%lx", res.r1); + report_info("x2: 0x%lx", res.r2); + report_info("x3: 0x%lx", res.r3); + report_info("x4: 0x%lx", res.r4); + report_info("x5: 0x%lx", res.r5); + report_info("x6: 0x%lx", res.r6); + report_info("x7: 0x%lx", res.r7); + } +} + +static void rsi_test_hvc(void) +{ + report_prefix_push("hvc"); + + /* Test that HVC causes Undefined exception, regardless of FID */ + install_exception_handler(EL1H_SYNC, ESR_EL1_EC_UNKNOWN, unknown_handler); + hvc_call(FID_SMCCC_VERSION); + hvc_call(FID_INVALID); + install_exception_handler(EL1H_SYNC, ESR_EL1_EC_UNKNOWN, NULL); + + report_prefix_pop(); +} + +static void host_call(unsigned int fid, unsigned long expected_x0) +{ + struct smccc_result res; + struct rsi_host_call __attribute__((aligned(256))) host_call_data = { 0 }; + + host_call_data.gprs[0] = fid; + + arm_smccc_smc(SMC_RSI_HOST_CALL, virt_to_phys(&host_call_data), + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, &res); + + if (res.r0) { + report(false, "RSI_HOST_CALL returned 0x%lx", res.r0); + } else { + if (host_call_data.gprs[0] == expected_x0) { + report(true, "FID=0x%x x0=0x%lx", + fid, host_call_data.gprs[0]); + } else { + report(false, "FID=0x%x x0=0x%lx expected=0x%lx", + fid, host_call_data.gprs[0], expected_x0); + report_info("x1: 0x%lx", host_call_data.gprs[1]); + report_info("x2: 0x%lx", host_call_data.gprs[2]); + report_info("x3: 0x%lx", host_call_data.gprs[3]); + report_info("x4: 0x%lx", host_call_data.gprs[4]); + report_info("x5: 0x%lx", host_call_data.gprs[5]); + report_info("x6: 0x%lx", host_call_data.gprs[6]); + } + } +} + +static void rsi_test_host_call(void) +{ + report_prefix_push("host_call"); + + /* Test that host calls return expected values */ + host_call(FID_SMCCC_VERSION, SMCCC_VERSION_1_1); + host_call(FID_INVALID, SMCCC_NOT_SUPPORTED); + + report_prefix_pop(); +} + static void rsi_test_version(void) { int version; @@ -36,6 +126,8 @@ static void rsi_test_version(void) int main(int argc, char **argv) { + int i; + report_prefix_push("rsi"); if (!is_realm()) { @@ -43,7 +135,23 @@ int main(int argc, char **argv) goto exit; } - rsi_test_version(); + if (argc < 2) { + rsi_test_version(); + rsi_test_host_call(); + rsi_test_hvc(); + } else { + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "version") == 0) { + rsi_test_version(); + } else if (strcmp(argv[i], "hvc") == 0) { + rsi_test_hvc(); + } else if (strcmp(argv[i], "host_call") == 0) { + rsi_test_host_call(); + } else { + report_abort("Unknown subtest '%s'", argv[1]); + } + } + } exit: return report_summary(); } diff --git a/arm/unittests.cfg b/arm/unittests.cfg index ce1b5ad9..3cdb1a98 100644 --- a/arm/unittests.cfg +++ b/arm/unittests.cfg @@ -280,5 +280,20 @@ groups = debug migration [realm-rsi] file = realm-rsi.flat groups = nodefault realms +extra_params = -append 'version' +accel = kvm +arch = arm64 + +[realm-host-call] +file = realm-rsi.flat +groups = nodefault realms +extra_params = -append 'host_call' +accel = kvm +arch = arm64 + +[realm-hvc] +file = realm-rsi.flat +groups = nodefault realms +extra_params = -append 'hvc' accel = kvm arch = arm64 From patchwork Fri Jan 27 11:40:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13118627 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 493DFC54EAA for ; Fri, 27 Jan 2023 12:29:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=q/l0EUma02ewGsrfghLuU0nzumI6Lvjnd+LalJeLVAM=; b=0j5x/jyzUMW6T2 tqK9Ooz0Ne/bYiqK1Zcb8sttI6+0Cj7UnSZmYjd5EMbcIwsRzTVw4Uurctrfiu1d9cLyj8cbINEoX vqKh1ezqrG5NNOpahh98MqAi9XAysRRZb3RpIPNpcs6pDSFDCTaQ48NMYrV4OXhfdV0NqOiACzDVo XKeIlHQNUpsPNm5Pp9cp9ZdU2FPxGFTbm8kwDePMfi8yGHRhKiJgAVz4p/goqjMYQUkdllF6mwvu3 JWAQU+j3pcnEOuxIKWa9nc1lnISsWCiwvGBOtF8d9YZZHzjM2gat4Fbbcwn+VCm/y4GPbWZW+UIfC 36Tm3XFPPp8H9fu2fqbQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNpc-00EYIE-AI; Fri, 27 Jan 2023 12:27:49 +0000 Received: from mail-am6eur05on2043.outbound.protection.outlook.com ([40.107.22.43] helo=EUR05-AM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN8M-00EEJ1-AW for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:43:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3H/KofU7Yu6fUxSmEWe39E/Gu3RJjuYRpnxRF7mLwfI=; b=tV+JGkMrQftoQRTL2cVT7OiePpomSaEz3/ExHzrx31m4QRJof1jJMrFuIw9hJXH7dZx6z3QoryV79uJ+b5CmQJYrCPuT96h/HjUS1SSPX1Y+M3beNuw4HmVi0cnrUiTVQKLl2VDseKdlDaxPtiFVRro/mSy1CfxO/V5Crpjd8zQ= Received: from DU2PR04CA0251.eurprd04.prod.outlook.com (2603:10a6:10:28e::16) by AM9PR08MB6274.eurprd08.prod.outlook.com (2603:10a6:20b:2d5::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23; Fri, 27 Jan 2023 11:42:51 +0000 Received: from DBAEUR03FT026.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:28e:cafe::84) by DU2PR04CA0251.outlook.office365.com (2603:10a6:10:28e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23 via Frontend Transport; Fri, 27 Jan 2023 11:42:50 +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 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT026.mail.protection.outlook.com (100.127.142.242) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.21 via Frontend Transport; Fri, 27 Jan 2023 11:42:50 +0000 Received: ("Tessian outbound 8038f0863a52:v132"); Fri, 27 Jan 2023 11:42:50 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 94b28eb650647488 X-CR-MTA-TID: 64aa7808 Received: from 3fa6661c85f2.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 300BB85B-DF74-4B62-800A-70313A127B26.1; Fri, 27 Jan 2023 11:42:44 +0000 Received: from EUR02-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 3fa6661c85f2.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 27 Jan 2023 11:42:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I+Ae76UG64Rb+TLIKIHAW8AOZxboFRQK5wYukOtAUL5ttcTJezG/USJshtCFmjWMgIasIVwtU3ld2UtDsbGk0I6UwM8eUNfIBObSZT9mTSRQRtPUB4haEbdiGpW8ug2HLyIpjIkmUP8d7qntEFLjM7qzSTdq2BKe1jTLCb+ozHC/l+U0jnG1P68eOrQw2SZP0Y6EBwlM4io7Hd2CAtv6aF1bIojthDXhGo0i6MHPsGJv4GtG/ypc2tUmmoBmnA1VrtJz9JUtgL+VF8dca2YXSsKWAiAOjTDmBzRwdkeCtLMfmlAcwQRGfAi/8FeTM22bwqh8CKOJMGmOOi8XJMh0Cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3H/KofU7Yu6fUxSmEWe39E/Gu3RJjuYRpnxRF7mLwfI=; b=eqkOLz+/+qVM94gD0N2ExU7ILB2C7TxD8Qlkotbj7DgpTuhRtNUD7OntQr110Cy7/EnpO0yGfJoye8EE6xWgeozwhaGFYGcJ5+zTIBVo+oz8mLLfbmi0qbWmy1nEol9ad8FoZcKl+MRRN3WPaJuMCT7NqevS1QVA9Up6/C9OFaiRKRt417j2JCMNYQBs81JSZuX44e7w8l2wg0Dtx75rLbzfTfF0YqAhFmZcNPlk877SwsTU1MGIswM4XKsvOrxI7EOt+llPaUWY0ppy1qlrFzLOttM+/QhlpQ1ooGlTD9Bc9jvsdBnCyJQiGnLgedJDjZxfc/ygqq9WAeB+aUhg7Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=linux.dev smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3H/KofU7Yu6fUxSmEWe39E/Gu3RJjuYRpnxRF7mLwfI=; b=tV+JGkMrQftoQRTL2cVT7OiePpomSaEz3/ExHzrx31m4QRJof1jJMrFuIw9hJXH7dZx6z3QoryV79uJ+b5CmQJYrCPuT96h/HjUS1SSPX1Y+M3beNuw4HmVi0cnrUiTVQKLl2VDseKdlDaxPtiFVRro/mSy1CfxO/V5Crpjd8zQ= Received: from AS9PR06CA0596.eurprd06.prod.outlook.com (2603:10a6:20b:486::31) by DB8PR08MB5452.eurprd08.prod.outlook.com (2603:10a6:10:111::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.22; Fri, 27 Jan 2023 11:42:41 +0000 Received: from AM7EUR03FT016.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:486:cafe::e3) by AS9PR06CA0596.outlook.office365.com (2603:10a6:20b:486::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23 via Frontend Transport; Fri, 27 Jan 2023 11:42:41 +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 Received: from nebula.arm.com (40.67.248.234) by AM7EUR03FT016.mail.protection.outlook.com (100.127.140.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6043.22 via Frontend Transport; Fri, 27 Jan 2023 11:42:41 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) 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.16; Fri, 27 Jan 2023 11:42:40 +0000 Received: from e124191.cambridge.arm.com (10.1.197.45) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Fri, 27 Jan 2023 11:42:35 +0000 From: Joey Gouly To: Andrew Jones , , CC: , Alexandru Elisei , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Suzuki K Poulose , "Thomas Huth" , Will Deacon , Zenghui Yu , , , , , Subhasish Ghosh Subject: [RFC kvm-unit-tests 15/27] arm: realm: Add test for FPU/SIMD context save/restore Date: Fri, 27 Jan 2023 11:40:56 +0000 Message-ID: <20230127114108.10025-16-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230127114108.10025-1-joey.gouly@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127114108.10025-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT016:EE_|DB8PR08MB5452:EE_|DBAEUR03FT026:EE_|AM9PR08MB6274:EE_ X-MS-Office365-Filtering-Correlation-Id: 28d8ce6b-9042-4cf2-b81d-08db005b9ece 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: 1sQTB5DLx+5RQCLMv9LvT5cZ+emGhI22P/936SHgbTE/PDSVRyAqb39bcPbb7BD56LM5DfCUk4n1YW17GFNRIFcu9nroeN4LxAj0rgugPV0a2MCd4Q0ZSdqEi7TpDsMAWEUbC2J+bo4gkqkZzcQJP5cXOnIilrK95NAXKWRIKSuLpBjgMTpf2/IHz8qaXllAsej8z2X/O99dVIva+41TDF5ey/IyTfepZn+lbS3JYH1avlPxBDGoORiETScXTjsIthnX8BZlsbD1ROftU+wiD1ygFhDtJPCRkoyt1oh518jKPHX2dlW6LsKNjzzsr194OHpuUQb9SKdjtjRbQ0PSfFPtXH2OpDnkbjw5CbTVYkojtNr9Erw7dlPjrcVFYHB8vnb7hGg8bUUVkhhdP0wkPpS4ogfjvD/yDB4ZWzHhB8G1ObqDgyaakygqBRjRlyZPRGt8zagzZPYUHhoLAOTq5taXJ+UDqinIObutW4HmtW2vUcLs1qNzhz1iuTuwkyBymbXZ949oUv6bUfupO4OEgTCKl0uraDylsQHF+84/zU01LsVslKq0G3krPBqy/XvvXFybejONOsyRLWLsAkShuKPAQyB3+EBy6IFQIOGwVIBiZK0+VyDOikPiPmotM1gFUgVgja4FjJmK8p/uIMBmMXlds+3+sGRhgc4RR35lHG9BdHdMK5AQga9obYViEAJ4LGm7AzXosAVW9fd3jy0yTBuNV7Z/gx/eO0/SeAUnhRwttrmf5SnOrV6Gj3l8O1we 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:(13230025)(4636009)(39860400002)(136003)(396003)(376002)(346002)(451199018)(36840700001)(40470700004)(46966006)(70586007)(4326008)(316002)(82310400005)(70206006)(8936002)(54906003)(36756003)(7416002)(5660300002)(8676002)(82740400003)(36860700001)(86362001)(356005)(81166007)(41300700001)(186003)(1076003)(26005)(6666004)(110136005)(336012)(426003)(47076005)(44832011)(40460700003)(40480700001)(2906002)(2616005)(478600001)(7696005)(83380400001)(2101003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB5452 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT026.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 5cb29121-41b8-48ea-add8-08db005b994e X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 39opAObmRJvIp4Y1TKsViYKzlBvH02/ZsaSbxkP+IRA7ybeZzRDiXwsf0pKIWCgomAU+P228sHpqIKnvQzrS57v78e4je7HQIi5kZBtbZrFnSRcz/BlwohSehobNQscaebjc4IhGDK/sAkgeTNrBMKKnm+1tvMjcZc7XEzihEa+pEmx1voDOLDrjVpUkKZUFmSDhzyup+EYgAQbIpem9pm7Djrbjd2HRi/NPF9Is8zfaKBkbGG1wZ/kvS3roWd6e6B0LaZZ1m00YO0cMP1tiy6LtszpE63oWUrmz9HSnzWyADCHkMi4rVR591wgmkx9V0MgkYT7kT3pzK8MUMCAVAR0+t9qwD834mVrxKalDXQd75pS3pffGbi9tZhUmarJmALQIDpBlB/G69Y9Jc1NqNAo+/PSvE0iILst+je4L+ZXgIRTD4SpjiNJGwr9XX0HgHxbGdvGiKivietVfqOjpfZs096tpkofWq7NJ48mD1sJoctZfGnSmykdvQCqSKeCLRiuOY9Y/J9gTNfAE5z+x473ksKLXl8DIy1+coICfGaitgYmcYFCrYCz/Bf69eWQ2EjiZDhyPEUWvrJYNxexvYyl4gwjw/UZkOBv6Vw1DEbpfeETsmk+JE8iSl3vVVQFUbs/gBMrOAQFRFLfqbIxQpgb4XyaU5QSzXgWKitYpwFG51ooLEzwMfuriwhWwOBdewphzX+cVR6x95Wl2/kJi4wzJGYP4Oe/R6D+/xWKO+Vk= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230025)(4636009)(346002)(396003)(39860400002)(376002)(136003)(451199018)(40470700004)(46966006)(36840700001)(2906002)(44832011)(36860700001)(336012)(426003)(5660300002)(8936002)(41300700001)(4326008)(478600001)(1076003)(26005)(186003)(8676002)(6666004)(2616005)(40480700001)(81166007)(82740400003)(83380400001)(47076005)(86362001)(40460700003)(70586007)(70206006)(7696005)(316002)(54906003)(110136005)(82310400005)(36756003)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2023 11:42:50.9428 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 28d8ce6b-9042-4cf2-b81d-08db005b9ece 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: DBAEUR03FT026.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR08MB6274 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034306_619198_A8F6A1FD X-CRM114-Status: GOOD ( 14.73 ) 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 From: Subhasish Ghosh Test that the FPU/SIMD registers are saved and restored correctly when context switching VCPUs. In order to test fpu/simd functionality, we need to make sure that kvm-unit-tests doesn't generate code that uses the fpu registers, as that might interfere with the test results. Thus make sure we compile the tests with -mgeneral-regs-only. Signed-off-by: Subhasish Ghosh Signed-off-by: Joey Gouly --- arm/Makefile.arm64 | 1 + arm/Makefile.common | 1 + arm/realm-fpu.c | 242 ++++++++++++++++++++++++++++++++++++++++++++ arm/unittests.cfg | 8 ++ 4 files changed, 252 insertions(+) create mode 100644 arm/realm-fpu.c diff --git a/arm/Makefile.arm64 b/arm/Makefile.arm64 index eed77d3a..90ec6815 100644 --- a/arm/Makefile.arm64 +++ b/arm/Makefile.arm64 @@ -34,6 +34,7 @@ tests += $(TEST_DIR)/micro-bench.flat tests += $(TEST_DIR)/cache.flat tests += $(TEST_DIR)/debug.flat tests += $(TEST_DIR)/realm-rsi.flat +tests += $(TEST_DIR)/realm-fpu.flat include $(SRCDIR)/$(TEST_DIR)/Makefile.common diff --git a/arm/Makefile.common b/arm/Makefile.common index 1bbec64f..b339b62d 100644 --- a/arm/Makefile.common +++ b/arm/Makefile.common @@ -25,6 +25,7 @@ CFLAGS += -std=gnu99 CFLAGS += -ffreestanding CFLAGS += -O2 CFLAGS += -I $(SRCDIR)/lib -I $(SRCDIR)/lib/libfdt -I lib +CFLAGS += -mgeneral-regs-only # We want to keep intermediate files .PRECIOUS: %.elf %.o diff --git a/arm/realm-fpu.c b/arm/realm-fpu.c new file mode 100644 index 00000000..35cfdf09 --- /dev/null +++ b/arm/realm-fpu.c @@ -0,0 +1,242 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2022 Arm Limited. + * All rights reserved. + */ + +#include +#include +#include + +#include + +#define CPU0_ID 0 +#define CPU1_ID (CPU0_ID + 1) +#define CPUS_MAX (CPU1_ID + 1) +#define RMM_FPU_QREG_MAX 32 +#define RMM_FPU_RESULT_PASS (-1U) + +#define fpu_reg_read(val) \ +({ \ + uint64_t *__val = (val); \ + asm volatile("stp q0, q1, [%0], #32\n\t" \ + "stp q2, q3, [%0], #32\n\t" \ + "stp q4, q5, [%0], #32\n\t" \ + "stp q6, q7, [%0], #32\n\t" \ + "stp q8, q9, [%0], #32\n\t" \ + "stp q10, q11, [%0], #32\n\t" \ + "stp q12, q13, [%0], #32\n\t" \ + "stp q14, q15, [%0], #32\n\t" \ + "stp q16, q17, [%0], #32\n\t" \ + "stp q18, q19, [%0], #32\n\t" \ + "stp q20, q21, [%0], #32\n\t" \ + "stp q22, q23, [%0], #32\n\t" \ + "stp q24, q25, [%0], #32\n\t" \ + "stp q26, q27, [%0], #32\n\t" \ + "stp q28, q29, [%0], #32\n\t" \ + "stp q30, q31, [%0], #32\n\t" \ + : "=r" (__val) \ + : \ + : "q0", "q1", "q2", "q3", \ + "q4", "q5", "q6", "q7", \ + "q8", "q9", "q10", "q11", \ + "q12", "q13", "q14", \ + "q15", "q16", "q17", \ + "q18", "q19", "q20", \ + "q21", "q22", "q23", \ + "q24", "q25", "q26", \ + "q27", "q28", "q29", \ + "q30", "q31", "memory"); \ +}) + +#define fpu_reg_write(val) \ +do { \ + uint64_t *__val = (val); \ + asm volatile("ldp q0, q1, [%0]\n\t" \ + "ldp q2, q3, [%0]\n\t" \ + "ldp q4, q5, [%0]\n\t" \ + "ldp q6, q7, [%0]\n\t" \ + "ldp q8, q9, [%0]\n\t" \ + "ldp q10, q11, [%0]\n\t" \ + "ldp q12, q13, [%0]\n\t" \ + "ldp q14, q15, [%0]\n\t" \ + "ldp q16, q17, [%0]\n\t" \ + "ldp q18, q19, [%0]\n\t" \ + "ldp q20, q21, [%0]\n\t" \ + "ldp q22, q23, [%0]\n\t" \ + "ldp q24, q25, [%0]\n\t" \ + "ldp q26, q27, [%0]\n\t" \ + "ldp q28, q29, [%0]\n\t" \ + "ldp q30, q31, [%0]\n\t" \ + : \ + : "r" (__val) \ + : "q0", "q1", "q2", "q3", \ + "q4", "q5", "q6", "q7", \ + "q8", "q9", "q10", "q11",\ + "q12", "q13", "q14", \ + "q15", "q16", "q17", \ + "q18", "q19", "q20", \ + "q21", "q22", "q23", \ + "q24", "q25", "q26", \ + "q27", "q28", "q29", \ + "q30", "q31", "memory");\ +} while (0) + +static void nr_cpu_check(int nr) +{ + if (nr_cpus < nr) + report_abort("At least %d cpus required", nr); +} +/** + * @brief check if the FPU/SIMD register contents are the same as + * the input data provided. + */ +static uint32_t __realm_fpuregs_testall(uint64_t *indata) +{ + /* 128b aligned array to read data into */ + uint64_t outdata[RMM_FPU_QREG_MAX * 2] + __attribute__((aligned(sizeof(__uint128_t)))) = { + [0 ... ((RMM_FPU_QREG_MAX * 2) - 1)] = 0 }; + uint8_t regcnt = 0; + uint32_t result = 0; + + if (indata == NULL) + report_abort("invalid data pointer received"); + + /* read data from FPU registers */ + fpu_reg_read(outdata); + + /* check is the data is the same */ + for (regcnt = 0; regcnt < (RMM_FPU_QREG_MAX * 2); regcnt += 2) { + if ((outdata[regcnt] != indata[regcnt % 4]) || + (outdata[regcnt+1] != indata[(regcnt+1) % 4])) { + report_info( + "fpu/simd save/restore failed for reg: q%d expected: %lx_%lx received: %lx_%lx\n", + regcnt / 2, indata[(regcnt+1) % 4], + indata[regcnt % 4], outdata[regcnt+1], + outdata[regcnt]); + } else { + /* populate a bitmask indicating which + * registers passed/failed + */ + result |= (1 << (regcnt / 2)); + } + } + + return result; +} + +/** + * @brief writes randomly sampled data into the FPU/SIMD registers. + */ +static void __realm_fpuregs_writeall_random(uint64_t **indata) +{ + + /* allocate 128b aligned memory */ + *indata = memalign(sizeof(__uint128_t), sizeof(uint64_t) * 4); + + /* populate the memory with sampled data from a counter */ + (*indata)[0] = get_cntvct(); + (*indata)[1] = get_cntvct(); + (*indata)[2] = get_cntvct(); + (*indata)[3] = get_cntvct(); + + /* write data into FPU registers */ + fpu_reg_write(*indata); +} + +static void realm_fpuregs_writeall_run(void *data) +{ + + uint64_t **indata = (uint64_t **)data; + + __realm_fpuregs_writeall_random(indata); +} + +static void realm_fpuregs_testall_run(void *data) +{ + + uint64_t *indata = (uint64_t *)data; + uint32_t result = 0; + + result = __realm_fpuregs_testall(indata); + report((result == RMM_FPU_RESULT_PASS), + "fpu/simd register save/restore mask: 0x%x", result); +} + +/** + * @brief This test uses two VCPU to test FPU/SIMD save/restore + * @details REC1 (vcpu1) writes random data into FPU/SIMD + * registers, REC0 (vcpu0) corrupts/overwrites the data and finally + * REC1 checks if the data remains unchanged in its context. + */ +static void realm_fpuregs_context_switch_cpu1(void) +{ + int target = CPU1_ID; + uint64_t *indata_remote = NULL; + uint64_t *indata_local = NULL; + + /* write data from REC1/VCPU1 */ + on_cpu(target, realm_fpuregs_writeall_run, &indata_remote); + + /* Overwrite from REC0/VCPU0 */ + __realm_fpuregs_writeall_random(&indata_local); + + /* check data consistency */ + on_cpu(target, realm_fpuregs_testall_run, indata_remote); + + free(indata_remote); + free(indata_local); +} + +/** + * @brief This test uses two VCPU to test FPU/SIMD save/restore + * @details REC0 (vcpu0) writes random data into FPU/SIMD + * registers, REC1 (vcpu1) corrupts/overwrites the data and finally + * REC0 checks if the data remains unchanged in its context. + */ +static void realm_fpuregs_context_switch_cpu0(void) +{ + + int target = CPU1_ID; + uint64_t *indata_local = NULL; + uint64_t *indata_remote = NULL; + uint32_t result = 0; + + /* write data from REC0/VCPU0 */ + __realm_fpuregs_writeall_random(&indata_local); + + /* Overwrite from REC1/VCPU1 */ + on_cpu(target, realm_fpuregs_writeall_run, &indata_remote); + + /* check data consistency */ + result = __realm_fpuregs_testall(indata_local); + report((result == RMM_FPU_RESULT_PASS), + "fpu/simd register save/restore mask: 0x%x", result); + + free(indata_remote); + free(indata_local); +} +/** + * checks if during realm context switch, FPU/SIMD registers + * are saved/restored. + */ +static void realm_fpuregs_context_switch(void) +{ + + realm_fpuregs_context_switch_cpu0(); + realm_fpuregs_context_switch_cpu1(); +} + +int main(int argc, char **argv) +{ + report_prefix_pushf("realm-fpu"); + + if (!is_realm()) + report_skip("Not running in Realm world, skipping"); + + nr_cpu_check(CPUS_MAX); + realm_fpuregs_context_switch(); + + return report_summary(); +} diff --git a/arm/unittests.cfg b/arm/unittests.cfg index 3cdb1a98..a60dc6a9 100644 --- a/arm/unittests.cfg +++ b/arm/unittests.cfg @@ -297,3 +297,11 @@ groups = nodefault realms extra_params = -append 'hvc' accel = kvm arch = arm64 + +# Realm FPU/SIMD test +[realm-fpu-context] +file = realm-fpu.flat +smp = 2 +groups = nodefault realms +accel = kvm +arch = arm64 From patchwork Fri Jan 27 11:40:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13118638 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 B5B82C38142 for ; Fri, 27 Jan 2023 12:33:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hDWFTGdkY8H85HNGmCKCA1wbZrkfBfAv/0FhCDz8Lz4=; b=oWnJ8uuCv1nsWS wzjV0Y4mstyp+OL2VUCibW/8wp54eL5ZPV0C5P5QhphA0Eb1p8CaLaI+1Rb1sySlSgYl/n+skw8ij yxpFDg2NFjg+FtkIIJ/aSUucHFye2JPVPRfLh7VL06ZagfeS+qo4k4AGSbLBfOgkn02lmsu5bOZGf 1B/oh+LWqrzErjVbRHCZgsvPcQHmnglQV+sf2AxEmwuwFI6wxqi620ALgJOccly08BDMr+sirOYPr u9cNLBVO06ixrw03HaDCkcvNLu1X3tsrTHaAKbfT3C9RmCfxjq5FRXbwD/oG0vcrxlzJKdGhAdHpK Hu9XFZ5URo6Ekl7uYN5g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNtX-00EZa8-5q; Fri, 27 Jan 2023 12:31:52 +0000 Received: from mail-vi1eur04on0608.outbound.protection.outlook.com ([2a01:111:f400:fe0e::608] helo=EUR04-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN8b-00EER8-G5 for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:43:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OaUsEIZHo1VrruVAtMnFib52+x175EA8f+O2M+UzY6Q=; b=eMOQ2YlQknLEZLxRqds7Q0ND10bMQdFFP5C4NK+pASHiROz80P+9tSB22XSoI0s6UiKP16VbzGQUtxDfdMSo1hF6bmONRxKez1JrOQdf5feoSa0pMDhL2c3p3ymY7WCr4lhGGfy2k5xIwoPihYqxxs/VKr8amIkCr1KJlwXk4bI= Received: from DUZPR01CA0102.eurprd01.prod.exchangelabs.com (2603:10a6:10:4bb::9) by DB9PR08MB6683.eurprd08.prod.outlook.com (2603:10a6:10:2ad::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23; Fri, 27 Jan 2023 11:42:59 +0000 Received: from DBAEUR03FT047.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:4bb:cafe::7b) by DUZPR01CA0102.outlook.office365.com (2603:10a6:10:4bb::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.37 via Frontend Transport; Fri, 27 Jan 2023 11:42:59 +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 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT047.mail.protection.outlook.com (100.127.143.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.21 via Frontend Transport; Fri, 27 Jan 2023 11:42:59 +0000 Received: ("Tessian outbound 8038f0863a52:v132"); Fri, 27 Jan 2023 11:42:59 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 3093725a19c96cd7 X-CR-MTA-TID: 64aa7808 Received: from f5c94ac5c241.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 83963576-4C02-49FC-A89F-081568359FA4.1; Fri, 27 Jan 2023 11:42:53 +0000 Received: from EUR03-DBA-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f5c94ac5c241.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 27 Jan 2023 11:42:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=baSuFzRt2dflh8qUwCRATN0ZwVVzoYJyECGABxAwVpPLACp8sRhVEa5qcv8v5M5rF4IkTKUj1CYXmWikg/ZbzNLtYw3l/dxEvo/dOyAIZw9YZw6iovAaxVLxISucczTYswvuox886ScAiCbOLzEbq7hiKHltIIVnBGglozvZk8Cn1MEkCgjrzDGYFGV+s8umv7SlKmZzh1Or1hYUMKE+x42kp80rhU+ch9qtgJRdlzxT+wjhCK5KJsjP9y2IzBhPJmXWB2Ww4+4sViZLXAdFJl2edUfyPzOI0zafJStzb6qUYMjkmA1ixgo2fsmjIilui/NnXbFgfjC+jgF1KcCheQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=OaUsEIZHo1VrruVAtMnFib52+x175EA8f+O2M+UzY6Q=; b=bI/z3IZmrkbobWK3uB9GWtzsKbNDM3Cjeay94EyA8jUK/bArUzdO02QQJzk0ZFj4JYqZxOgKkRebUhIUGsgz6Bo3bkqoP0nSa8EGxqq6aptWk2oAqFTRasoWoDZYgY504v+LcFq8unI/VAQ8PPqjV8NM8j9GZhQuHfH1jzAWwK2Ih3SoKzqYirY2hlP1cklBRaaWhCJU/kv3cpAErH9flG3JTCr2e7M/+7/aOg/WqygS8q5d8kujxBPa6oLCxCGFBsqYKI3xFmFyRzIIvexV+T5FYzrznmjDTho0nI1/wnmgBFg9t0NTcShFyOxG6aDRSCzkmgsZlRD4vq9pz+W4kQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=linux.dev smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OaUsEIZHo1VrruVAtMnFib52+x175EA8f+O2M+UzY6Q=; b=eMOQ2YlQknLEZLxRqds7Q0ND10bMQdFFP5C4NK+pASHiROz80P+9tSB22XSoI0s6UiKP16VbzGQUtxDfdMSo1hF6bmONRxKez1JrOQdf5feoSa0pMDhL2c3p3ymY7WCr4lhGGfy2k5xIwoPihYqxxs/VKr8amIkCr1KJlwXk4bI= Received: from AM6PR05CA0001.eurprd05.prod.outlook.com (2603:10a6:20b:2e::14) by DBAPR08MB5749.eurprd08.prod.outlook.com (2603:10a6:10:1af::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23; Fri, 27 Jan 2023 11:42:47 +0000 Received: from AM7EUR03FT051.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:2e:cafe::79) by AM6PR05CA0001.outlook.office365.com (2603:10a6:20b:2e::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23 via Frontend Transport; Fri, 27 Jan 2023 11:42:47 +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 Received: from nebula.arm.com (40.67.248.234) by AM7EUR03FT051.mail.protection.outlook.com (100.127.140.64) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6043.22 via Frontend Transport; Fri, 27 Jan 2023 11:42:47 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) 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.16; Fri, 27 Jan 2023 11:42:46 +0000 Received: from e124191.cambridge.arm.com (10.1.197.45) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Fri, 27 Jan 2023 11:42:40 +0000 From: Joey Gouly To: Andrew Jones , , CC: , Alexandru Elisei , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Suzuki K Poulose , "Thomas Huth" , Will Deacon , Zenghui Yu , , , , , Djordje Kovacevic Subject: [RFC kvm-unit-tests 16/27] arm: realm: Add tests for in realm SEA Date: Fri, 27 Jan 2023 11:40:57 +0000 Message-ID: <20230127114108.10025-17-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230127114108.10025-1-joey.gouly@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127114108.10025-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT051:EE_|DBAPR08MB5749:EE_|DBAEUR03FT047:EE_|DB9PR08MB6683:EE_ X-MS-Office365-Filtering-Correlation-Id: 356af4ab-3e37-4ad1-c9b0-08db005ba3cd 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: pZjh5UYrExFlcIRmFeDeH6ef2gX42Q8PIPTLlFMudGmyfpZs07oSGQjWVXBTYeEWOaL5XwihVAAWOMZGV1tMnZA4RapQ25SdgrmuB2oruHhiiMkxzSJIeyHx6Lr3t77i+nXLWQruT/GV9qQDTIB2e3Tp411U0SP3gtiIQ3SQoY9BHZA0wi5Bm8QwUJTpnMU7uJj6i2iUUrq45ZZ/Z2UfMKrdxmwYgm1SsAjIj6ZbHWyCX7m3rHgAfn71rQwn0E6VFo7NK30wtvihHGBZUj8WJAwffz9mDbK4bU+/TtXFVn7a7e+e1+Y6g4+8QHHYkS7LJTuH447diw1qxFGppl2kNuaiqjvLiZJOhcqKheSXREfMno1TRKODitG3mv+jO5sO8Pk6lSFMrxM+WVXCoFVSxTe18BsW42/fjrGzzIvKMqWfEPx3gQOzr7JkoNxphWOeGvkxUV2KjSHv7AXd0bRTpN87EU1EBHeRBM2ZTubBkjrAJvvFFoSmyV+lJLM5Xq9k+rKJikQhfP3LCLcAtDAkkgHE0KcBtNQkDwOewfbsio/w/+KrFMtm6Q38kp0V1nCmjzWDtfTcZbzJhoDzcLBA2XZnN+06b6+Yao6SISw27gXTTkAniOZiCc49HbYHV6XYGOqDuhFZic3rVLsOQ8u/hpVCtGkka13Y5Mbc55Q163kAXp3YiQyMaeXV7pyuLVcjiArqjpANQ4FPMJnOH1SRNTen3FAY+HgqDZQ/FiY/gM8RpDoK9VC9jGL7tzqZX78A 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:(13230025)(4636009)(346002)(39860400002)(396003)(376002)(136003)(451199018)(40470700004)(36840700001)(46966006)(83380400001)(36860700001)(336012)(40460700003)(36756003)(82310400005)(82740400003)(426003)(316002)(5660300002)(110136005)(54906003)(47076005)(7416002)(356005)(2616005)(86362001)(40480700001)(81166007)(26005)(70586007)(186003)(7696005)(478600001)(6666004)(2906002)(4326008)(8936002)(70206006)(8676002)(1076003)(44832011)(41300700001)(2101003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5749 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT047.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: d8c897ae-a372-4964-dd5a-08db005b9c9e X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: b+ZPPJ0ivzGQVlLV15UkMQ6PkYtvYNoVZdUuBu+6418MS+6Xa5Gs8xKqdr/7K47tWROSUXW44Mt2C8fujVbUO+egYOIHltWV3bkaEFaBWKtg17a2aNshM75qzNewF4jzP9gen4HhRRkkrFFKzYWHqq/+29ye3OYUdYV1Lq6bs41HpY3GANqs/ranJ6Nw1bYwgb/IWdT+bKBns6NoEFXTkKP4ZQDOAOCnsChHsxS8kgTPqXknRNUilaB26DlYNQE1nkdjZEszisv76VYHSNgJZ5S5yER6JM0ZKyDLcceVXmMdQ6d72IE5khraKLH4aQZN7/ivgxkuAM44c0rhKh45B8xKCdgrcbPdAFuChogmOhz6CJfafl2TdZ0z2uU+V9ASyumdHBzh1bDSmLyAWIQCfdyzW0bUc7UYq+J7gLAkS2EjY2vCV85/a+HVY+CBHdFM3X9PQrLcNH9CW4xS3ITD6b/nEvkAx5yO6pxOM2aTqFc/UAxCk/6ZrXIspjoE1BP41u2eYG5eiA2qk7pS1c7wgcgSoBce1fgfky0LxTyDMWuweRzciFFMeic6Ta43lAMO5cBUWB+moFeOqrW6MKv15F8r0HlRWKlkNDUOidWoG/LZIPkAPS+mNlRGfqtYFkUHFhoix/noMjBzC4f7nNLYDeMefgauN+t46+SNHAY7RI776h9j5/mx6rvkrS9JAkvdZf14U4bfGjWn2M6CRwaShB31RLCtXSRmhD2BphTX2xA= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230025)(4636009)(396003)(376002)(346002)(136003)(39860400002)(451199018)(36840700001)(46966006)(40470700004)(81166007)(5660300002)(47076005)(8936002)(82310400005)(41300700001)(36756003)(7696005)(186003)(478600001)(26005)(1076003)(6666004)(54906003)(2616005)(86362001)(70206006)(426003)(40480700001)(110136005)(316002)(70586007)(83380400001)(8676002)(4326008)(336012)(44832011)(82740400003)(36860700001)(40460700003)(2906002)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2023 11:42:59.3097 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 356af4ab-3e37-4ad1-c9b0-08db005ba3cd 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: DBAEUR03FT047.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB6683 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034321_766400_701C91A4 X-CRM114-Status: GOOD ( 18.27 ) 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 From: Djordje Kovacevic The RMM/Host could inject Synchronous External Aborts in to the Realm for various reasons. RMM injects the SEA for : * Instruction/Data fetch from an IPA that is in RIPAS_EMPTY state * Instruction fetch from an Unprotected IPA. Trigger these conditions from within the Realm and verify that the SEAs are received. Signed-off-by: Djordje Kovacevic Signed-off-by: Suzuki K Poulose Signed-off-by: Joey Gouly --- arm/Makefile.arm64 | 1 + arm/realm-sea.c | 143 +++++++++++++++++++++++++++++++++++++++++++++ arm/unittests.cfg | 6 ++ 3 files changed, 150 insertions(+) create mode 100644 arm/realm-sea.c diff --git a/arm/Makefile.arm64 b/arm/Makefile.arm64 index 90ec6815..8448af36 100644 --- a/arm/Makefile.arm64 +++ b/arm/Makefile.arm64 @@ -35,6 +35,7 @@ tests += $(TEST_DIR)/cache.flat tests += $(TEST_DIR)/debug.flat tests += $(TEST_DIR)/realm-rsi.flat tests += $(TEST_DIR)/realm-fpu.flat +tests += $(TEST_DIR)/realm-sea.flat include $(SRCDIR)/$(TEST_DIR)/Makefile.common diff --git a/arm/realm-sea.c b/arm/realm-sea.c new file mode 100644 index 00000000..5ef3e2a4 --- /dev/null +++ b/arm/realm-sea.c @@ -0,0 +1,143 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2022 Arm Limited. + * All rights reserved. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef void (*empty_fn)(void); + +static bool test_passed; + +/* + * The virtual address of the page that the test has made the access to + * in order to cause the I/DAbort with I/DFSC = Synchronous External Abort. + */ +static void* target_page_va; + +/* + * Ensure that the @va is the executable location from EL1: + * - SCTLR_EL1.WXN must be off. + * - Disable the access from EL0 (controlled by AP[1] in PTE). + */ +static void enable_instruction_fetch(void* va) +{ + unsigned long sctlr = read_sysreg(sctlr_el1); + if (sctlr & SCTLR_EL1_WXN) { + sctlr &= ~SCTLR_EL1_WXN; + write_sysreg(sctlr, sctlr_el1); + isb(); + flush_tlb_all(); + } + + mmu_clear_user(current_thread_info()->pgtable, (u64)va); +} + +static void data_abort_handler(struct pt_regs *regs, unsigned int esr) +{ + if ((esr & ESR_EL1_FSC_MASK) == ESR_EL1_FSC_EXTABT) + test_passed = true; + + report_info("esr = %x", esr); + /* + * Advance the PC to complete the test. + */ + regs->pc += 4; +} + +static void data_access_to_empty(void) +{ + test_passed = false; + target_page_va = alloc_page(); + phys_addr_t empty_ipa = virt_to_phys(target_page_va); + + arm_set_memory_shared(empty_ipa, SZ_4K); + + install_exception_handler(EL1H_SYNC, ESR_EL1_EC_DABT_EL1, data_abort_handler); + READ_ONCE(((char*)target_page_va)[0x55]); + install_exception_handler(EL1H_SYNC, ESR_EL1_EC_DABT_EL1, NULL); + + report(test_passed, " "); +} + +static void instruction_abort_handler(struct pt_regs *regs, unsigned int esr) +{ + if (((esr & ESR_EL1_FSC_MASK) == ESR_EL1_FSC_EXTABT) && + (regs->pc == (u64)target_page_va)) + test_passed = true; + + report_info("esr = %x", esr); + /* + * Simulate the RET instruction to complete the test. + */ + regs->pc = regs->regs[30]; +} + +static void instr_fetch_from_empty(void) +{ + phys_addr_t empty_ipa; + + test_passed = false; + target_page_va = alloc_page(); + enable_instruction_fetch(target_page_va); + + empty_ipa = virt_to_phys((void*)target_page_va); + + arm_set_memory_shared(empty_ipa, SZ_4K); + + install_exception_handler(EL1H_SYNC, ESR_EL1_EC_IABT_EL1, instruction_abort_handler); + /* + * This should cause the IAbort with IFSC = SEA + */ + ((empty_fn)target_page_va)(); + install_exception_handler(EL1H_SYNC, ESR_EL1_EC_IABT_EL1, NULL); + + report(test_passed, " "); +} + +static void instr_fetch_from_unprotected(void) +{ + test_passed = false; + /* + * The test will attempt to execute an instruction from the start of + * the unprotected IPA space. + */ + target_page_va = vmap(PTE_NS_SHARED, SZ_4K); + enable_instruction_fetch(target_page_va); + + install_exception_handler(EL1H_SYNC, ESR_EL1_EC_IABT_EL1, instruction_abort_handler); + /* + * This should cause the IAbort with IFSC = SEA + */ + ((empty_fn)target_page_va)(); + install_exception_handler(EL1H_SYNC, ESR_EL1_EC_IABT_EL1, NULL); + + report(test_passed, " "); +} + +int main(int argc, char **argv) +{ + report_prefix_push("in_realm_sea"); + + report_prefix_push("data_access_to_empty"); + data_access_to_empty(); + report_prefix_pop(); + + report_prefix_push("instr_fetch_from_empty"); + instr_fetch_from_empty(); + report_prefix_pop(); + + report_prefix_push("instr_fetch_from_unprotected"); + instr_fetch_from_unprotected(); + report_prefix_pop(); + + return report_summary(); +} diff --git a/arm/unittests.cfg b/arm/unittests.cfg index a60dc6a9..bc2354c7 100644 --- a/arm/unittests.cfg +++ b/arm/unittests.cfg @@ -305,3 +305,9 @@ smp = 2 groups = nodefault realms accel = kvm arch = arm64 + +[realm-sea] +file = realm-sea.flat +groups = nodefault realms +accel = kvm +arch = arm64 From patchwork Fri Jan 27 11:40:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13118628 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 EB2E9C61DB3 for ; Fri, 27 Jan 2023 12:30:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=csoRlfZtFd2WvK3zaTtU1bB1itGle1wffcf53Z14YYI=; b=wFUHHwaiXCmNBA yTqDlHEI0p5iX0sIbZW8/eDuFoCbWVi6MvnC+vpnVZ/FC3SdPY824PPkRl/qLSb6DzYAhhmocXZ7b xtDa5U4OTO4/h1xplHbRznYOvxZc8TK9OS0fySiycvq+0jAa4yr3iutDKITdtpzyxlsaRujkB7++j +b2/BmFeG6/9hWKHmwie2h+ePDQoknj7S09B+U3rJ1JMtryAmKUhESGc0HAwFz0fU+ZhEmzFeCjzc YdwqdNi7Dn6a5NbWyUAnoFR0s0GmRmA7wDrue4hcn3Kjka4fxe+h4leIUsps13S2O1k9W6Y1vWPtM kZGOCyIUQe+hASXnD4BQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNqg-00EYeV-9r; Fri, 27 Jan 2023 12:28:57 +0000 Received: from mail-ve1eur01on0616.outbound.protection.outlook.com ([2a01:111:f400:fe1f::616] helo=EUR01-VE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN8O-00EEKC-9v for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:43:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0T4rpun+mT/zPp4XRSj3yIBLvDhCB0Z4b27exMQi8r4=; b=el8E7ULEYiPkeG85m9DqLJRI97TzTIzXqATpWs+iYcSGomXVglUfePrU2jYGX1XtuO3OqN7cwu9BuqCgMoy9GfWyXC8YxIuA/RQGjGl1xYGzybK3qcFzTebjkTCkUmLPh9g0/VyFOY4auTruelODtKE689kAVI2bjpk5kp6Bkcg= Received: from AM5PR0101CA0036.eurprd01.prod.exchangelabs.com (2603:10a6:206:16::49) by VI1PR08MB5438.eurprd08.prod.outlook.com (2603:10a6:803:12e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23; Fri, 27 Jan 2023 11:43:02 +0000 Received: from AM7EUR03FT063.eop-EUR03.prod.protection.outlook.com (2603:10a6:206:16:cafe::40) by AM5PR0101CA0036.outlook.office365.com (2603:10a6:206:16::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.34 via Frontend Transport; Fri, 27 Jan 2023 11:43:02 +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 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM7EUR03FT063.mail.protection.outlook.com (100.127.140.221) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.17 via Frontend Transport; Fri, 27 Jan 2023 11:43:02 +0000 Received: ("Tessian outbound 0d7b2ab0f13d:v132"); Fri, 27 Jan 2023 11:43:01 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: c4868fa8c4408566 X-CR-MTA-TID: 64aa7808 Received: from 64b8f445e458.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id EAB6B48A-58FC-4A68-8893-7E96A2D08957.1; Fri, 27 Jan 2023 11:42:55 +0000 Received: from EUR03-AM7-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 64b8f445e458.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 27 Jan 2023 11:42:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=etK3qgSeruHU4/LZ4G+WlPeE71Oe7um8H5sLbPQYSp/USAi1xz5W0z4rkS8RigRECUIH+GJXeRfPm+KAzPz1nKG1wHfovrrqGgzD1ghZmjDHeuBnPLjUmSrldZa26V1PIjvptwicTQZQCRoxPOgjog+meHOwUH1xBuNrZrG/dNLgVTHLtFFlRICDrg1UJqmCf9+2giDyaL23Ai1XPVkWKDeQf+EQLv5G+BDnvdQamFuhCto8yu9e9JdbthUomGpxuAzQMnjDn7rCTBRGtNWWEVjJpq6Tul/P02Wdp9n1pkbrbHMTdWnGdDSC8bItQOqcp7fMg0kXmJxkkh/MvL2Rxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=0T4rpun+mT/zPp4XRSj3yIBLvDhCB0Z4b27exMQi8r4=; b=L5e1XJWnJixb6ZQIIWYGJgVrj2Q6s3bIqnXMTwHeRAT7r0GMykh59Jr3Vw1ox1qJUc5pCNUZ9p6D38fWXqpSlcvVzUk0c3MpT9OzN0Afl8y9og8yrOY+qrYjG7BfVUJw060Y2mUq/I85rVJ5KadIyE9d/9El3uyhBRa7kZ4++BAiuKIB4xJPDZ/YGSLJUMVWOg8GWlmRQZcoIV9lCcNslukYa6UPJdixzVX/h4w41dDBvfArdExjw8Q3lohd0eF8+Eq6RNgsJ17jI/cXuCAw5E8aVEL2hqlh8Uqy6jIjwaor+n/pEIGeD8MRLF5kOyOH8mLNl5SJija1sXbpmGgzqg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=linux.dev smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0T4rpun+mT/zPp4XRSj3yIBLvDhCB0Z4b27exMQi8r4=; b=el8E7ULEYiPkeG85m9DqLJRI97TzTIzXqATpWs+iYcSGomXVglUfePrU2jYGX1XtuO3OqN7cwu9BuqCgMoy9GfWyXC8YxIuA/RQGjGl1xYGzybK3qcFzTebjkTCkUmLPh9g0/VyFOY4auTruelODtKE689kAVI2bjpk5kp6Bkcg= Received: from DB6PR07CA0067.eurprd07.prod.outlook.com (2603:10a6:6:2a::29) by PR3PR08MB5657.eurprd08.prod.outlook.com (2603:10a6:102:87::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23; Fri, 27 Jan 2023 11:42:53 +0000 Received: from DBAEUR03FT046.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:2a:cafe::4d) by DB6PR07CA0067.outlook.office365.com (2603:10a6:6:2a::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.20 via Frontend Transport; Fri, 27 Jan 2023 11:42:53 +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 Received: from nebula.arm.com (40.67.248.234) by DBAEUR03FT046.mail.protection.outlook.com (100.127.142.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6043.21 via Frontend Transport; Fri, 27 Jan 2023 11:42:52 +0000 Received: from AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Fri, 27 Jan 2023 11:42:52 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) 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.16; Fri, 27 Jan 2023 11:42:52 +0000 Received: from e124191.cambridge.arm.com (10.1.197.45) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Fri, 27 Jan 2023 11:42:46 +0000 From: Joey Gouly To: Andrew Jones , , CC: , Alexandru Elisei , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Suzuki K Poulose , "Thomas Huth" , Will Deacon , Zenghui Yu , , , , Subject: [RFC kvm-unit-tests 17/27] lib/alloc_page: Add shared page allocation support Date: Fri, 27 Jan 2023 11:40:58 +0000 Message-ID: <20230127114108.10025-18-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230127114108.10025-1-joey.gouly@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127114108.10025-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT046:EE_|PR3PR08MB5657:EE_|AM7EUR03FT063:EE_|VI1PR08MB5438:EE_ X-MS-Office365-Filtering-Correlation-Id: 72161bf1-dcec-4519-e558-08db005ba575 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: UsfsmbNNTGlyOhMoOsykrLly5ru6rRbtZP5CWveMKVCt+o+mPAVvhgIKByZqJqI3XrWsX7y2XlV5feZw88KDrtPX7B9p57Rs/TBbOEt97XUobPV4qK4ITk+J3DW9Tfxsln0NnbmXqsjI4dEAsZlJFB+mXVVg0qwt48AZ3KEd1ZEpe3jJyY5uUODp4nNV9LhE9t7LBhKMn9aLzvnvJ0KVXrQV9NOSo7K2OZR92gQEaEL8So1zuqKnfYf9obdImvmiL15RyifETjCn9OpSYPGYcKXudo87jZnau5PqOnOKCe9Kd/iTG+g0K0HbQNHnCluDGvQPmIHC67zWegrIuAyTyzpJjnNEx4xayMkkkjLfmEJe38K2Ixh0Wbnr6yNl2DeRnAqQItsUpwqe2JBWfS/ev+xMGUzW6SQcf9EZr28iI61kFfLeUjsJOBGtJJtX/XU3OGmrJORr97UQwXRtRZTnSJ+tVp4+zF9hgYrrTcxJatnCHkJq3UMyM2GYzHY+mk5RtC4w0Y17gWPmpH0w8bTQwwnFOFUs8KrAW0D01d9xB39tqcDGKDiZtzBKdWLqKlHnp7o56Ib7i1/ZqyRqvJLBMLXZTWfi7BPjMb+9tPJ5IOJ1q1kQ5/q7IuZspxvvC0auOkTKWMVS4KbWZNw/XArFIaKJ/5/vqYZCtJweMPllGeqE2kJxJw/bjNqBZGmgVJ6Yk2q6S/dgg8ttYKZNpaviVQF3MIcKUc2DhCilTt/YWFXg/SOVDLA3KDj8h1N2TmO8 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:(13230025)(4636009)(39860400002)(346002)(376002)(136003)(396003)(451199018)(40470700004)(46966006)(36840700001)(81166007)(36860700001)(36756003)(356005)(41300700001)(86362001)(336012)(5660300002)(7696005)(40480700001)(8936002)(70206006)(4326008)(70586007)(83380400001)(7416002)(47076005)(426003)(82310400005)(8676002)(54906003)(110136005)(316002)(478600001)(2616005)(44832011)(40460700003)(26005)(1076003)(186003)(82740400003)(6666004)(2906002)(36900700001)(2101003);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR08MB5657 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT063.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 6790246f-9a4b-4038-da75-08db005b9ffe X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HdjjwjcYLw0joHjxMWiOXWRtd2+PWVQlUxJfdvTjxIF1aPfBtrMM7hpY0UJrUp7RYQ3uLJXvdpae+n8fewjqYQEA98uDYs6+ZW+F+VpSpi99uCza1LoMaRLxmXOro+6FI2pFi9b8FOXRRWepkbPQnz6anMU7Txig5yzb8w22mINB19hlq7rM7P9tKUtAdEDz8Dcuf8+uJf2VspnfBj2hBWELQvHgWHeJQvTDC9bMYosEhsncwSi8t3pmwHDTcLBFcKoEPbHvP/rqsZzkIZTWFV6VnOxCYYSX3+v8tnPizY2hvlp2NHXhhryQs6poWm9Sq1WIWeiH+y5qZsFedbpbtBIeIWPQL9VkCD4txWUJihOS+HJ/GXD4I+dg860v4wjbwJqW0VnN0mKxGxLLnjjl8mGh6KIvXp6nn2vzfXABosthM1zil0A9VrJJ4/zLq7B80YCBDWNjQd0RBrOAogp8qPVlH07BAn8XHlbwqeQow2/s5dH7fKYKzWbsh53pjJc9H6lyeHAsLP7h1nU8LAFZpto/mRaH9T8PZr84gcLoGGsviRFLAETmgyB/rIpE9byUt7GUi9kVhUFaAlQ0xyxPU2pNg+csKKxM/74Qcq/Rf1jcBDsPr/tqtiHW/6/Vltxo9bjXZzqCY9yl0TYmcOusj2fbVVrckuVWqaSZ9HGoKWUa2Y0kldo1QgybsPu6N1Q/UT7PSKokZyDo3QeY5vonx7TH5jmC7ZvxZ7bIRHObMm8= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230025)(4636009)(346002)(39860400002)(396003)(376002)(136003)(451199018)(36840700001)(40470700004)(46966006)(41300700001)(83380400001)(36756003)(86362001)(2616005)(54906003)(110136005)(82310400005)(316002)(478600001)(7696005)(6666004)(26005)(186003)(40460700003)(336012)(426003)(107886003)(1076003)(4326008)(70206006)(70586007)(47076005)(8676002)(2906002)(81166007)(40480700001)(8936002)(44832011)(82740400003)(36860700001)(5660300002)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2023 11:43:02.0423 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 72161bf1-dcec-4519-e558-08db005ba575 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: AM7EUR03FT063.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB5438 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034308_685581_99E975FF X-CRM114-Status: GOOD ( 18.35 ) 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 Add support for allocating "pages" that can be shared with the host. Or in other words, decrypted pages. This is achieved by adding hooks for setting a memory region as "encrypted" or "decrypted", which can be overridden by the architecture specific backends. Also add a new flag - FLAG_SHARED - for allocating shared pages. The page allocation/free routines get a "_shared_" variant too. These will be later used for Realm support and tests. Signed-off-by: Joey Gouly --- lib/alloc_page.c | 34 +++++++++++++++++++++++++++++++--- lib/alloc_page.h | 24 ++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/lib/alloc_page.c b/lib/alloc_page.c index 84f01e11..8b811b15 100644 --- a/lib/alloc_page.c +++ b/lib/alloc_page.c @@ -53,6 +53,20 @@ static struct mem_area areas[MAX_AREAS]; /* Mask of initialized areas */ static unsigned int areas_mask; /* Protects areas and areas mask */ + +#ifndef set_memory_encrypted +static inline void set_memory_encrypted(unsigned long mem, unsigned long size) +{ +} +#endif + +#ifndef set_memory_decrypted +static inline void set_memory_decrypted(unsigned long mem, unsigned long size) +{ +} +#endif + + static struct spinlock lock; bool page_alloc_initialized(void) @@ -263,7 +277,7 @@ static bool coalesce(struct mem_area *a, u8 order, pfn_t pfn, pfn_t pfn2) * - no pages in the memory block were already free * - no pages in the memory block are special */ -static void _free_pages(void *mem) +static void _free_pages(void *mem, u32 flags) { pfn_t pfn2, pfn = virt_to_pfn(mem); struct mem_area *a = NULL; @@ -281,6 +295,9 @@ static void _free_pages(void *mem) p = pfn - a->base; order = a->page_states[p] & ORDER_MASK; + if (flags & FLAG_SHARED) + set_memory_encrypted((unsigned long)mem, BIT(order) * PAGE_SIZE); + /* ensure that the first page is allocated and not special */ assert(IS_ALLOCATED(a->page_states[p])); /* ensure that the order has a sane value */ @@ -320,7 +337,14 @@ static void _free_pages(void *mem) void free_pages(void *mem) { spin_lock(&lock); - _free_pages(mem); + _free_pages(mem, 0); + spin_unlock(&lock); +} + +void free_pages_shared(void *mem) +{ + spin_lock(&lock); + _free_pages(mem, FLAG_SHARED); spin_unlock(&lock); } @@ -353,7 +377,7 @@ static void _unreserve_one_page(pfn_t pfn) i = pfn - a->base; assert(a->page_states[i] == STATUS_SPECIAL); a->page_states[i] = STATUS_ALLOCATED; - _free_pages(pfn_to_virt(pfn)); + _free_pages(pfn_to_virt(pfn), 0); } int reserve_pages(phys_addr_t addr, size_t n) @@ -401,6 +425,10 @@ static void *page_memalign_order_flags(u8 al, u8 ord, u32 flags) if (area & BIT(i)) res = page_memalign_order(areas + i, al, ord, fresh); spin_unlock(&lock); + + if (res && (flags & FLAG_SHARED)) + set_memory_decrypted((unsigned long)res, BIT(ord) * PAGE_SIZE); + if (res && !(flags & FLAG_DONTZERO)) memset(res, 0, BIT(ord) * PAGE_SIZE); return res; diff --git a/lib/alloc_page.h b/lib/alloc_page.h index 060e0418..847a7fda 100644 --- a/lib/alloc_page.h +++ b/lib/alloc_page.h @@ -21,6 +21,7 @@ #define FLAG_DONTZERO 0x10000 #define FLAG_FRESH 0x20000 +#define FLAG_SHARED 0x40000 /* Returns true if the page allocator has been initialized */ bool page_alloc_initialized(void); @@ -121,4 +122,27 @@ int reserve_pages(phys_addr_t addr, size_t npages); */ void unreserve_pages(phys_addr_t addr, size_t npages); +/* Shared page operations */ +static inline void *alloc_pages_shared(unsigned long order) +{ + return alloc_pages_flags(order, FLAG_SHARED); +} + +static inline void *alloc_page_shared(void) +{ + return alloc_pages_shared(0); +} + +void free_pages_shared(void *mem); + +static inline void free_page_shared(void *page) +{ + free_pages_shared(page); +} + +static inline void free_pages_shared_by_order(void *mem, unsigned long order) +{ + free_pages_shared(mem); +} + #endif From patchwork Fri Jan 27 11:40:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13118630 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 4B896C54EAA for ; Fri, 27 Jan 2023 12:32:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Dh2aqp0eENiFv+6pnaaFfimnw9as1sDxGRyUpv/bBOc=; b=3nDkU/Vss9dJCy f3/rlyo6Rwk65ohw58hmIxSFke7q/vf1STmsVC9DkRDLyNxzX1UvQZsEeRz1S6pUM3vjD3n2inDVZ Y1VAN+e1bPe6dHe6Ja+McEKWX7xC6T7/X9zeuiSXDOetxPZs7+MPoZ8kt5loCrViALkjy/1bL8Vkk VzbMEHaOEmdYlWN6LUudXUuxDW+nUb11HTr85IaBY3WWwdav6ZStGedO+a+vuMQsTj6GaFyP6rTu/ w+6SvmUtxin1AeVJW/9hdPTxbvNjqoOdrU0movKw7uI1MYyUhASTZ166+5zMOD8VpHd1nvcOHNFyG hZB0xPm1CJAuRx1SvDOQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNsT-00EZEX-Q6; Fri, 27 Jan 2023 12:30:48 +0000 Received: from mail-he1eur04on2080.outbound.protection.outlook.com ([40.107.7.80] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN8X-00EEOD-46 for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:43:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=t5FjfwVBwygdym6y9NRMbHUpKfxtgFRoaRFzE5MRdEU=; b=Tt10Z9AiMTuspdx2UP4vvMiLSmh4VEYMyAb6f4d2A72z25BwfPKgjkDWCeMgNeGrChe2vWWJRinOLi1QLNjD51mTot1LmBuGOhBnSAzOuII7Cf//025xE0CBYUODBS5k0edmT+x2p25VOnVsTFeLQDSTUQhJEx9HdsfeyrzXioQ= Received: from AS8PR04CA0159.eurprd04.prod.outlook.com (2603:10a6:20b:331::14) by AM8PR08MB5603.eurprd08.prod.outlook.com (2603:10a6:20b:1d4::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23; Fri, 27 Jan 2023 11:43:10 +0000 Received: from AM7EUR03FT057.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:331:cafe::c6) by AS8PR04CA0159.outlook.office365.com (2603:10a6:20b:331::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.22 via Frontend Transport; Fri, 27 Jan 2023 11:43:10 +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 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM7EUR03FT057.mail.protection.outlook.com (100.127.140.117) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.22 via Frontend Transport; Fri, 27 Jan 2023 11:43:10 +0000 Received: ("Tessian outbound 333ca28169fa:v132"); Fri, 27 Jan 2023 11:43:10 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: a621d2503924eac8 X-CR-MTA-TID: 64aa7808 Received: from 3299abcf3b4b.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 42734D87-1B4B-4381-83A8-ADEC2DFE4D1A.1; Fri, 27 Jan 2023 11:43:03 +0000 Received: from EUR03-AM7-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 3299abcf3b4b.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 27 Jan 2023 11:43:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dsmAqhDZiXsMXpqd4Q0hBQF4ro3nNV6riWhArRUSojKMpy+uZy52rPJAgtszX5kTMIPuKhZPX1tdvHmm0iwbQSC5QVjiwKR07ULdsbcs3bE3Q46sedDnTsIS5Q4qwEfSvmX97Jf/AhYKpcDv7wDEWuBzszPCkhKCXGYs1WVfEZwRjCcj3BNEM95DqC9pymNwPqrrRxr8z63xOamcNoYpBGWUDLXzGre+AglatzUMA1CApePzEoGNNvUmR+JfULlNw5twCFsQ6erXdNt4BppWzHvSThZWZ3mBMn9Lb6vbxopa9/kkyRHQm9Zx4tGbVRhiUn2x5JaZLz4G3IfsUaZOtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=t5FjfwVBwygdym6y9NRMbHUpKfxtgFRoaRFzE5MRdEU=; b=nH7Hw+IIwyJt5incNgS/++pKEOzQq4biCIolq9m2npGu82fym8Zw7bInkLzzMo7vr/oprI5fV1mttr+fyNTEo6dPlb/a3Vkl0yw09fsuSh7PG0US0B2xt9UCWn4FGfFwVvPJw01pYiRudtBXSTUGsN60zQ99wI8q29/sjQ4YB1PL+CTESIZLbsBuwcDoTgKGdZ8sFSn1ZuY8krqWdxz2U0sslaa/X5lnIcOxvfCrudHdVsH69vZaXe1XB6JsOwxccDQ2Gt3Y499P2M+ud8oTaJDvkaWj1Dz9CHaiUS11oa0GgVkx658vQ8YuFrBAKPP0Ahax/Zl24eUzxnVKpHEYlw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=linux.dev smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=t5FjfwVBwygdym6y9NRMbHUpKfxtgFRoaRFzE5MRdEU=; b=Tt10Z9AiMTuspdx2UP4vvMiLSmh4VEYMyAb6f4d2A72z25BwfPKgjkDWCeMgNeGrChe2vWWJRinOLi1QLNjD51mTot1LmBuGOhBnSAzOuII7Cf//025xE0CBYUODBS5k0edmT+x2p25VOnVsTFeLQDSTUQhJEx9HdsfeyrzXioQ= Received: from AM6PR10CA0044.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:80::21) by AS8PR08MB8160.eurprd08.prod.outlook.com (2603:10a6:20b:561::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23; Fri, 27 Jan 2023 11:42:59 +0000 Received: from AM7EUR03FT006.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:80:cafe::a1) by AM6PR10CA0044.outlook.office365.com (2603:10a6:209:80::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23 via Frontend Transport; Fri, 27 Jan 2023 11:42:59 +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 Received: from nebula.arm.com (40.67.248.234) by AM7EUR03FT006.mail.protection.outlook.com (100.127.141.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6043.22 via Frontend Transport; Fri, 27 Jan 2023 11:42:58 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) 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.16; Fri, 27 Jan 2023 11:42:57 +0000 Received: from e124191.cambridge.arm.com (10.1.197.45) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Fri, 27 Jan 2023 11:42:52 +0000 From: Joey Gouly To: Andrew Jones , , CC: , Alexandru Elisei , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Suzuki K Poulose , "Thomas Huth" , Will Deacon , Zenghui Yu , , , , Subject: [RFC kvm-unit-tests 18/27] arm: gic-v3-its: Use shared pages wherever needed Date: Fri, 27 Jan 2023 11:40:59 +0000 Message-ID: <20230127114108.10025-19-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230127114108.10025-1-joey.gouly@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127114108.10025-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT006:EE_|AS8PR08MB8160:EE_|AM7EUR03FT057:EE_|AM8PR08MB5603:EE_ X-MS-Office365-Filtering-Correlation-Id: f9d9dc6c-e545-43c0-a550-08db005baa76 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: Y6Na1gYNSfIFPFmAAsVTq4EsI/YhfrpjuUunJU4DpofTTnlFerHTlwpDNDwbw4jekRyCVkGX+En2c5OxxhiNeMtRCcqdguZeW5MP6LkUCprTRs3J/8JxAzOZZrq8EfNkx5oeI772L/Nba9tDaiZfQ/op+3jeuZ1plOqAS+k/xP6cQqDfnNb97EgsKtzRIfm3Hxjx4FlcFOr+jqB+Rybr9lizg/X5NwzAOf9LSmIIN7K+5KhN1fmcdcXvGX/9AdOiz/o69lYSOTNx98wk+8aTtOUwKJzBaWR+iKZRWaqQYWA7rRyT8guFDrynSXCv0CPJfS/hjaVCJl0CdS3C27zpBHMCJCUnz1iTdJ7fq8zWqQ6x2m7SgfeGNVVvSb+CFQXX5qsQmwGepr6nIyvIm70LpJ4zIT4Dj3eS5b/kyc8p8cQPxXm+kcAuzebk+sccGWcZXQVoJDt2biGOlhAVLlJ3RMy01Vrj0zJo/PLPokNC1a/jYStb9yxH/2Uv1TOzmgRpxFqqkdggUyQvKNn06UTwhG26I3YKimZOGBvh6v2P8keeQk5oAcc4FWbUW+Iw7aF23PNtJmWwVX3KOblnWEHI4YCl21Z42ynwNMs/Lef3bygERH4ic6XhO+9F3VG3RMw0s0p7p/fkOjbicFKJMqdb2szAp3TxPoZM4a4UAtRANjzLmUZS0e4lMxyFSKg8FePBTVvnQsEDPrXNI2wRT0AHw8Dzl5XDpiMahQOJTvOU0QZIEoml92UQj0oVe9JlPTNs 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:(13230025)(4636009)(136003)(396003)(39860400002)(346002)(376002)(451199018)(40470700004)(36840700001)(46966006)(41300700001)(70206006)(26005)(186003)(356005)(70586007)(8936002)(8676002)(83380400001)(5660300002)(44832011)(1076003)(7416002)(81166007)(478600001)(36756003)(2616005)(36860700001)(47076005)(426003)(54906003)(110136005)(7696005)(86362001)(336012)(82310400005)(40480700001)(4326008)(40460700003)(2906002)(316002)(82740400003)(2101003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB8160 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT057.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 5d224b18-d083-4de9-1107-08db005ba39f X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Z+MNGi0gIvR9d4XkQv06fcC43Yesq8QGxsb+JmnqlHBWGOCxBVenBOqkBaU7ywIW/egNJdMkAB0SDdRXcqJBzYCcjrkFw+ZO43K5sfIOsL3RwcS3VlvO+mTc5+gSR4PV7eFvU2LwRBZDD+48GnVd32kDvEMPxPhKk642CV6X4B6EcK9lhqFLvOpDB7SdK8XcqpE846C/8sHUr+dQB1jrcAl4/Y3N3F4FeZHKEFhP3l+2dALrcLKWKJDvoHSDCuRsWFbZ6PL94gAv+kkgT3HUlSGIwetrRtrrGIhFIof1zIpNGsnBjj4gI+GD6W0EW084asJMuN8BA0IsLZzIvrZ2RG9XO87AmuH8afegFIITMn+C45zrMY01Suyj095TTYY285KZmQFtCs4k02zJebpiQYReKwPm4BwXJKabuz7PRfRHLQFiLqHkL/sNN4HblgRHVBS9NYhqQQEhiMA5yVz5lG37jUjS6VqeclWqsp1M2sGm10V3BWyKOwj+ngq9bNk1FW9A9lHooscbSfOEyInCR/fCzndhMa22NhMKquYB3DbnQREizyB7baOsB/eLONd8x0NhIE8GCUDD5kYODiwhoWDs2wcrCgcL/XaIniYNHsuO+hn9rBs/GDeRhbMfwW8wI9yfuP2rlPkyyo972x5cUYy9rM38A4h1lsv5JH2JtxgJtRaSwFSlt2wUSkPnK5/7tSEdZ0fDYDzqjacef9FDhjBqF1fsnODM8xcCCuoFSGI= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230025)(4636009)(39860400002)(376002)(346002)(136003)(396003)(451199018)(46966006)(40470700004)(36840700001)(82740400003)(186003)(26005)(44832011)(36860700001)(5660300002)(81166007)(1076003)(336012)(2906002)(8936002)(36756003)(83380400001)(40460700003)(7696005)(107886003)(41300700001)(2616005)(82310400005)(86362001)(4326008)(316002)(478600001)(70586007)(70206006)(47076005)(110136005)(54906003)(40480700001)(8676002)(426003)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2023 11:43:10.4358 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f9d9dc6c-e545-43c0-a550-08db005baa76 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: AM7EUR03FT057.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB5603 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034317_259202_109354FD X-CRM114-Status: GOOD ( 12.50 ) 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 From: Suzuki K Poulose GICv3-ITS is emulated by the host and thus we should allocate shared pages for access by the host. Make sure the allocations are shared. Signed-off-by: Suzuki K Poulose Signed-off-by: Joey Gouly --- lib/arm/gic-v3.c | 6 ++++-- lib/arm64/gic-v3-its.c | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/arm/gic-v3.c b/lib/arm/gic-v3.c index 2f7870ab..813cd5a6 100644 --- a/lib/arm/gic-v3.c +++ b/lib/arm/gic-v3.c @@ -171,7 +171,9 @@ void gicv3_lpi_alloc_tables(void) u64 prop_val; int cpu; - gicv3_data.lpi_prop = alloc_pages(order); + assert(gicv3_redist_base()); + + gicv3_data.lpi_prop = alloc_pages_shared(order); /* ID bits = 13, ie. up to 14b LPI INTID */ prop_val = (u64)(virt_to_phys(gicv3_data.lpi_prop)) | 13; @@ -186,7 +188,7 @@ void gicv3_lpi_alloc_tables(void) writeq(prop_val, ptr + GICR_PROPBASER); - gicv3_data.lpi_pend[cpu] = alloc_pages(order); + gicv3_data.lpi_pend[cpu] = alloc_pages_shared(order); pend_val = (u64)(virt_to_phys(gicv3_data.lpi_pend[cpu])); writeq(pend_val, ptr + GICR_PENDBASER); } diff --git a/lib/arm64/gic-v3-its.c b/lib/arm64/gic-v3-its.c index 2c69cfda..07dbeb81 100644 --- a/lib/arm64/gic-v3-its.c +++ b/lib/arm64/gic-v3-its.c @@ -54,7 +54,7 @@ static void its_baser_alloc_table(struct its_baser *baser, size_t size) void *reg_addr = gicv3_its_base() + GITS_BASER + baser->index * 8; u64 val = readq(reg_addr); - baser->table_addr = alloc_pages(order); + baser->table_addr = alloc_pages_shared(order); val |= virt_to_phys(baser->table_addr) | GITS_BASER_VALID; @@ -70,7 +70,7 @@ static void its_cmd_queue_init(void) unsigned long order = get_order(SZ_64K >> PAGE_SHIFT); u64 cbaser; - its_data.cmd_base = alloc_pages(order); + its_data.cmd_base = alloc_pages_shared(order); cbaser = virt_to_phys(its_data.cmd_base) | (SZ_64K / SZ_4K - 1) | GITS_CBASER_VALID; @@ -123,7 +123,7 @@ struct its_device *its_create_device(u32 device_id, int nr_ites) new->nr_ites = nr_ites; n = (its_data.typer.ite_size * nr_ites) >> PAGE_SHIFT; - new->itt = alloc_pages(get_order(n)); + new->itt = alloc_pages_shared(get_order(n)); its_data.nr_devices++; return new; From patchwork Fri Jan 27 11:41:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13118657 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 5EDA0C54EAA for ; Fri, 27 Jan 2023 13:02:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=tNYFAe3lwgvyiFWH91MFHaaTZ2wFwH87WO6JabgpWhM=; b=1NOY8weT/ZhfHM RmS3RCbkbZZaALwWO11//+LrTtxwnb5YknsEbeKHDe2OoGC2gq10m1woLGdUR8STOjyISUQ8+fgJM VupCW132yK4X8m6eumFXBcN4281Xqj4SxOBHK+4vUO/gx84auCBBR6UhRIvfI/peIVkHouU0FTzz/ 4s0o9YgDjudz1qPMSFJ57ZLkSGUoDDp50N73GtVzDpN2UsKeTOED6ksXIh4bWK5zIbecgZ2oFPjh1 iN0VHKltRCYDZ0QagamRX3IHTYCSSnZ50ytMst344eGQwvTUsA4uVVQNt67/rTcLdeLKXvqTz4oNi oBpjMcVrTOuOZKu+CBUw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLOKi-00EnqH-IO; Fri, 27 Jan 2023 13:00:04 +0000 Received: from mail-dbaeur03on2088.outbound.protection.outlook.com ([40.107.104.88] helo=EUR03-DBA-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNMp-00EKtp-FO for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:58:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MDAYQ8+UYEE6DLe0LNm6SQFVNecp3wXZDOjg6HprJE8=; b=i1etITeCghsbXAO2U6Vn9SY59NVE65obHNuTWo7VkrhWeRmQisYZ4VVSQKqd46CthXkffI/dDh+VnsUkw5TZQdKK6oKCheSYhZxi999PbC4/n4xH2LBf4iodvFU3LNliv0n2Kj2eKiSQdxMQKOn31GPmkorqOPt5KcSMRpfZqIM= Received: from AS9PR06CA0135.eurprd06.prod.outlook.com (2603:10a6:20b:467::22) by DB3PR08MB9010.eurprd08.prod.outlook.com (2603:10a6:10:42b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.22; Fri, 27 Jan 2023 11:43:15 +0000 Received: from AM7EUR03FT033.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:467:cafe::c0) by AS9PR06CA0135.outlook.office365.com (2603:10a6:20b:467::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23 via Frontend Transport; Fri, 27 Jan 2023 11:43:15 +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 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM7EUR03FT033.mail.protection.outlook.com (100.127.140.129) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.22 via Frontend Transport; Fri, 27 Jan 2023 11:43:15 +0000 Received: ("Tessian outbound 333ca28169fa:v132"); Fri, 27 Jan 2023 11:43:15 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: c833f2fdfedaec41 X-CR-MTA-TID: 64aa7808 Received: from c1aeac7245cb.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 6A05F7D2-29A8-4ED7-A2D2-C0C273B25438.1; Fri, 27 Jan 2023 11:43:08 +0000 Received: from EUR03-AM7-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id c1aeac7245cb.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 27 Jan 2023 11:43:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FsxZLAdpJdQMUmuoFs8yklMQPqG1n9s0ICb1KtE2qUQyie9AlRtvgwInA+HD16o0j/zUTg1+QuufanbBR6iggU2/JYLGabjLaRPOSiNpkVT5TNodjwV/jomAjp2DR9n+JFADd1NBfDRSSN6n6EiAZh9EgDe7ZqpXPnIuFQ7ICX7kk/xzTJTOT9pxQeuJyb+nV4I++uWieD6qUv5FgtGYRlMbmzS2S37FTCooPvVuqZZq5WPVSMAFfa04R0xd4/QZvfl7ix11bv7kcZ/+BXUCQGrhVkLQrXIaoYpLfcO9UEi4r+u555jxsG21Zdy/SWdx2+RPeFrFpRsBlBasH/Uv0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=MDAYQ8+UYEE6DLe0LNm6SQFVNecp3wXZDOjg6HprJE8=; b=fovWUULQeWcSA6KSPIyNUqDdEGE+uave4IjYo9pq7m9I3CmZuKDQ7yl50f7W3hi/uX5LINJxP9tjSb3zmPJUfO78ua+jhVMBSblpzSVOaRcUkn7p2uH6sSo+cNS6TWAxcdEgn+aoP/I9mj+iIdvUasklSCRbMzlA5X+WO+cqW9mrci+6Z5dnM1lzxgoGzAD9aUcQ2N9HOMD6zSvW6ObccTxisuRSKf8Mu7X4dE7fV22WO4pfxgeqzethMiRyqpWuHgIHDL1b1syISrrcGBt1fae7/FKRngWwjp35qbCdoWTcjSZDvfErGMSqscEEj8Np9toQLMHr9iXeJLoVcxICTg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=linux.dev smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MDAYQ8+UYEE6DLe0LNm6SQFVNecp3wXZDOjg6HprJE8=; b=i1etITeCghsbXAO2U6Vn9SY59NVE65obHNuTWo7VkrhWeRmQisYZ4VVSQKqd46CthXkffI/dDh+VnsUkw5TZQdKK6oKCheSYhZxi999PbC4/n4xH2LBf4iodvFU3LNliv0n2Kj2eKiSQdxMQKOn31GPmkorqOPt5KcSMRpfZqIM= Received: from DB7PR05CA0003.eurprd05.prod.outlook.com (2603:10a6:10:36::16) by VI1PR08MB5408.eurprd08.prod.outlook.com (2603:10a6:803:130::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23; Fri, 27 Jan 2023 11:43:04 +0000 Received: from DBAEUR03FT056.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:36:cafe::b6) by DB7PR05CA0003.outlook.office365.com (2603:10a6:10:36::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.22 via Frontend Transport; Fri, 27 Jan 2023 11:43:04 +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 Received: from nebula.arm.com (40.67.248.234) by DBAEUR03FT056.mail.protection.outlook.com (100.127.142.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6043.23 via Frontend Transport; Fri, 27 Jan 2023 11:43:04 +0000 Received: from AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Fri, 27 Jan 2023 11:43:03 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) 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.16; Fri, 27 Jan 2023 11:43:03 +0000 Received: from e124191.cambridge.arm.com (10.1.197.45) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Fri, 27 Jan 2023 11:42:57 +0000 From: Joey Gouly To: Andrew Jones , , CC: , Alexandru Elisei , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Suzuki K Poulose , "Thomas Huth" , Will Deacon , Zenghui Yu , , , , Subject: [RFC kvm-unit-tests 19/27] arm: realm: Enable memory encryption Date: Fri, 27 Jan 2023 11:41:00 +0000 Message-ID: <20230127114108.10025-20-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230127114108.10025-1-joey.gouly@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127114108.10025-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT056:EE_|VI1PR08MB5408:EE_|AM7EUR03FT033:EE_|DB3PR08MB9010:EE_ X-MS-Office365-Filtering-Correlation-Id: 1646d641-9c5c-4dbd-cd24-08db005bad60 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: 7rnr+3R6a1LCsyy2J/XdmpbnBnEKzsyEnWDDcuWElPJszZCIG11NceBbqP1j0pFQOFzQnPEkeJX5HZ+pad8GP35fRYCGX7+R1KLhX10QyopUyJOpuQzCUAaDsHL37LqfxHVtXVnM/mbQnt1onL0yJFAPYOFEx6ZqumwSAGSNnB64bs/MbaAoPftfcAJq4uTKG16yxb3q509Dcc9II7Z2LV9TVM3t2PlxGak0a5YvABof9T90kraWMKPua2h77hSwK6KUR/hG03J2Fncu3rGm30/ruj5tnOof3AHLbAdYqb4QrQQn2z+3XQegxAfwJynA8IESZzZPKfmievvEtZg/NQbsRkyURYmyTHu/VNFxhX/dqy5tBsJtVttFfjy0pj5lQ5kvBHZW5VeR8njhpqBSX4TroxXOkioZOfdzoliRolIw7dybC3quMaMn/zc+JgyfsOyOgdXRFf5oUQrkKPedLWEBwRPyZ/3+J5CJzlZ4IYB7FOIZcAIFROps9lxvDExfj+Wuu/hGLN+2i9Z9WtmcX/diVeDRG0xTsCa6Sr3kEKJfUGHr6uwmMNVJ8uX8CWtz2UpzzH5i7eaplWgaVEJV/dn22ucMf3s8ez+flVOae6LSI2dUxX/vNfhTBGh4/Q1zMHpbqUC8lbkSjXeNuvVTJL4TTHRV8b1m5IqkoHq9ZTQE/aPOZDnHbQyCY0mg5Ym+TadMcqkFagzmFsjCtSa1kX+U+fc8Oew+u5YLziBS3xzj3S2eNKhCKtQH2UgnUp9Y 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:(13230025)(4636009)(39860400002)(376002)(136003)(396003)(346002)(451199018)(46966006)(40470700004)(36840700001)(82310400005)(36756003)(2906002)(6666004)(7416002)(41300700001)(8936002)(70206006)(70586007)(44832011)(5660300002)(8676002)(40480700001)(4326008)(316002)(36860700001)(40460700003)(86362001)(110136005)(7696005)(54906003)(478600001)(356005)(1076003)(81166007)(186003)(26005)(82740400003)(83380400001)(2616005)(426003)(336012)(47076005)(2101003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB5408 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT033.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 5c348f23-71da-4fc9-a759-08db005ba6cb X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: x7gmKDLnLgK231i5cauSAiKFT4YPHu3o06WndaUxTBsiFpkvvyWJHj/83z4V8aOIiinLFY0MCzx2EhAU+KBPpPTQNBMWHzR2A969Daw2tmG2QrA2qivnQ7Dbi0+bOIuQhGqUG4/ISZRq3ixiJFwMGF6j2coXIGMwWGZ0wleOllgRHDZAQgn4sOjjelYQoqL4oh/9L8LnVxyQM1zsIF6xsh63zYqdFTNrm9dYxlJtLavaJp6rvt8TQQ+X/tMcuazw8LR9vK1TRaKqPCvHVjTOrQn3quizz8CHByOKJz9TYjziTap6Q1LG4yZ+N8avXJVrJ3Ek6syCM6NzFhwUUzJqbUKnv4Q6LGXSx0ggCOu5dwuGRDOMry3+gNZxrXUaT78/k62Aefgcqj7jgl04qEpRfQ3RXKPPE2lfufLz2sSfHOTviCjOSa2Duj8sHyPy8TkSr5oTWptvUs3RwVHDrD25kHALLmQWLpiNMXsEqOuboN+eG//ZQT1Y2PTKCas0Z35hH1N5kWn7rthdmlbccEa4TGOpcEfDFwd3LQD7K1hAD6lEMJhlh3pSxlGfzN3NPr3P7rbjPNMJXBOwr54huZoxDoQe8dYdrZPoYCXtPfH4dJBcXmLCeaROkd+G10TvgFcA7bgXWXANzLw4eIKVAJKaAHKGLb329LogxkYpwbOtUCIe48qhTpGzR7vNLoKZn0uCxgrerIaiDl/hdwbR8x4TKboxJhsGfMTRP3Am/KO914w= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230025)(4636009)(396003)(136003)(39860400002)(376002)(346002)(451199018)(40470700004)(36840700001)(46966006)(6666004)(36860700001)(8936002)(426003)(41300700001)(47076005)(336012)(40460700003)(83380400001)(81166007)(7696005)(40480700001)(86362001)(82740400003)(70586007)(82310400005)(110136005)(54906003)(70206006)(36756003)(8676002)(316002)(2616005)(1076003)(478600001)(107886003)(4326008)(186003)(26005)(44832011)(5660300002)(2906002)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2023 11:43:15.3258 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1646d641-9c5c-4dbd-cd24-08db005bad60 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: AM7EUR03FT033.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR08MB9010 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_035803_681505_C0A2B62B X-CRM114-Status: GOOD ( 16.85 ) 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 From: Suzuki K Poulose Enable memory encryption support for Realms. When a page is "decrypted", we set the RIPAS to EMPTY, hinting to the hypervisor that it could reclaim the page backing the IPA. Also the pagetable is updated with the PTE_NS_SHARED attrbiute, whic in effect turns the "ipa" to the unprotected alias. Similarly for "encryption" we mark the IPA back to RIPAS_RAM and clear the PTE_NS_SHARED attribute. Signed-off-by: Suzuki K Poulose Signed-off-by: Joey Gouly --- lib/arm/mmu.c | 65 ++++++++++++++++++++++++++++++++++++++++++++-- lib/arm64/asm/io.h | 6 +++++ 2 files changed, 69 insertions(+), 2 deletions(-) diff --git a/lib/arm/mmu.c b/lib/arm/mmu.c index 2b5a7141..d4fbe56a 100644 --- a/lib/arm/mmu.c +++ b/lib/arm/mmu.c @@ -22,6 +22,7 @@ #include pgd_t *mmu_idmap; +unsigned long idmap_end; /* Used by Realms, depends on IPA size */ unsigned long prot_ns_shared = 0; @@ -30,6 +31,11 @@ unsigned long phys_mask_shift = 48; /* CPU 0 starts with disabled MMU */ static cpumask_t mmu_enabled_cpumask; +static bool is_idmap_address(phys_addr_t pa) +{ + return pa < idmap_end; +} + bool mmu_enabled(void) { /* @@ -92,12 +98,17 @@ static pteval_t *get_pte(pgd_t *pgtable, uintptr_t vaddr) return &pte_val(*pte); } +static void set_pte(uintptr_t vaddr, pteval_t *p_pte, pteval_t pte) +{ + WRITE_ONCE(*p_pte, pte); + flush_tlb_page(vaddr); +} + static pteval_t *install_pte(pgd_t *pgtable, uintptr_t vaddr, pteval_t pte) { pteval_t *p_pte = get_pte(pgtable, vaddr); - WRITE_ONCE(*p_pte, pte); - flush_tlb_page(vaddr); + set_pte(vaddr, p_pte, pte); return p_pte; } @@ -122,6 +133,39 @@ phys_addr_t virt_to_pte_phys(pgd_t *pgtable, void *mem) + ((ulong)mem & (PAGE_SIZE - 1)); } +/* + * __idmap_set_range_prot - Apply permissions to the given idmap range. + */ +static void __idmap_set_range_prot(unsigned long virt_offset, size_t size, pgprot_t prot) +{ + pteval_t *ptep; + pteval_t default_prot = PTE_TYPE_PAGE | PTE_AF | PTE_SHARED; + + while (size > 0) { + pteval_t pte = virt_offset | default_prot | pgprot_val(prot); + + if (!is_idmap_address(virt_offset)) + break; + /* Break before make : Clear the PTE entry first */ + ptep = install_pte(mmu_idmap, (uintptr_t)virt_offset, 0); + /* Now apply the changes */ + set_pte((uintptr_t)virt_offset, ptep, pte); + + size -= PAGE_SIZE; + virt_offset += PAGE_SIZE; + } +} + +static void idmap_set_range_shared(unsigned long virt_offset, size_t size) +{ + return __idmap_set_range_prot(virt_offset, size, __pgprot(PTE_WBWA | PTE_USER | PTE_NS_SHARED)); +} + +static void idmap_set_range_protected(unsigned long virt_offset, size_t size) +{ + __idmap_set_range_prot(virt_offset, size, __pgprot(PTE_WBWA | PTE_USER)); +} + void mmu_set_range_ptes(pgd_t *pgtable, uintptr_t virt_offset, phys_addr_t phys_start, phys_addr_t phys_end, pgprot_t prot) @@ -190,6 +234,7 @@ void *setup_mmu(phys_addr_t phys_end, void *unused) } mmu_enable(mmu_idmap); + idmap_end = phys_end; return mmu_idmap; } @@ -278,3 +323,19 @@ void mmu_clear_user(pgd_t *pgtable, unsigned long vaddr) flush_tlb_page(vaddr); } } + +void set_memory_encrypted(unsigned long va, size_t size) +{ + if (is_realm()) { + arm_set_memory_protected(__virt_to_phys(va), size); + idmap_set_range_protected(va, size); + } +} + +void set_memory_decrypted(unsigned long va, size_t size) +{ + if (is_realm()) { + arm_set_memory_shared(__virt_to_phys(va), size); + idmap_set_range_shared(va, size); + } +} diff --git a/lib/arm64/asm/io.h b/lib/arm64/asm/io.h index be19f471..3f71254d 100644 --- a/lib/arm64/asm/io.h +++ b/lib/arm64/asm/io.h @@ -89,6 +89,12 @@ static inline void *phys_to_virt(phys_addr_t x) return (void *)__phys_to_virt(x); } +extern void set_memory_decrypted(unsigned long va, size_t size); +#define set_memory_decrypted set_memory_decrypted + +extern void set_memory_encrypted(unsigned long va, size_t size); +#define set_memory_encrypted set_memory_encrypted + #include #endif /* _ASMARM64_IO_H_ */ From patchwork Fri Jan 27 11:41:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13118648 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 0B8E4C54EAA for ; Fri, 27 Jan 2023 12:40:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=yImw5WuTLrcnKIIdEXICtejkSpaUI+z4CxMkgwkK3xU=; b=4Rijgms3WzqJmb qMNZMYx70MSefeKzvE4a6+uzLNqWEDOPF22/6T8pLmRZxPWa2Q6C3IrY8BvT4KEdKb9QVMgutH2rL f5CctUF6aEkWe6SM8KGKLJ7ygfNkrFQjz6H9olbqjeIJwatZ93ySGihKwU2D+U5GpmvLc5Iaaz5GL n4D2lBaxGyi4jqE+InTVKZ6VPJiEGD/aandLO/Lkea9CtAfG1YLkJKlY9nJ+zTXuMMD9OuQUKDfQ8 qKKD+Z4EuuDiK1JDF7WSHFXdEXDpi08PJKOQfh9b/LKeE4yV+BJvUfqna4fG+iXwlFHK+oVx766/t jCuzCnnDu/NB2wupIo/Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLO01-00Ed35-NI; Fri, 27 Jan 2023 12:38:37 +0000 Received: from mail-db5eur01on062a.outbound.protection.outlook.com ([2a01:111:f400:fe02::62a] helo=EUR01-DB5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN8x-00EEbx-TO for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:43:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lbtS9Kcg831sCdIhPFu0ucGohn4Enumb1k5jv0h4C88=; b=hOss0l1J1oWSbYaWOFSgXQOx7vrcPvdNujep4U0jFOegEz4TqJrioNrDBAAA2id6kG/YGRWiOFfFgyg8WiXWyi/fhM8XzL7cyJix31kKYyEmGeheXV/aXzIf6M17tu90E77HaiCwbjzj8qkcXyYfRHdu0EqFS915Z9JVpz2SfSY= Received: from AM5PR04CA0002.eurprd04.prod.outlook.com (2603:10a6:206:1::15) by DB9PR08MB7560.eurprd08.prod.outlook.com (2603:10a6:10:307::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33; Fri, 27 Jan 2023 11:43:22 +0000 Received: from AM7EUR03FT005.eop-EUR03.prod.protection.outlook.com (2603:10a6:206:1:cafe::e) by AM5PR04CA0002.outlook.office365.com (2603:10a6:206:1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.22 via Frontend Transport; Fri, 27 Jan 2023 11:43:22 +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 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM7EUR03FT005.mail.protection.outlook.com (100.127.140.218) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.25 via Frontend Transport; Fri, 27 Jan 2023 11:43:22 +0000 Received: ("Tessian outbound 333ca28169fa:v132"); Fri, 27 Jan 2023 11:43:22 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: b85a7ebb9964932e X-CR-MTA-TID: 64aa7808 Received: from 738540edc373.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id EC0D18AF-BF20-4C69-91A5-A02C540EDDBB.1; Fri, 27 Jan 2023 11:43:16 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 738540edc373.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 27 Jan 2023 11:43:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WsxAjcVEP7krukz7VSRBAELHWftQGMD8Q/7jLK5WXrene0cT2Wk/eh3yJMJImF7kzP7X4fR6x1T+FHtm1b3zGBsSdV3ZpdSidrXW7KzSe5Rf5b0TFphDZcX/gS7mhXdd/DrIZLBaNuTFHIQYjG/NRJdE+uUZw6oST0fGNcfzZDDcf8yO6ECqoX8crHaJ2Eg/DV9dBfi+hM+rgFz5jCCCKeozfHX2A5zeW+nX2FVy+EI94DiqqZKxCd/6TafbT0zagDOHilnnn17cD6CtdzIA8ipSUrK0WwxHMWsIpblhcpfgVecOM45P0irI/ZzwmuAZsM0Z193jkrEdhkaDhOLkIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lbtS9Kcg831sCdIhPFu0ucGohn4Enumb1k5jv0h4C88=; b=Uy38XnrJvfjPNOj5Ml9BtCT/4ijl+ndD7GlZimLy3WnRktETCLwP0GjPG798cV14qG7smeW0RPusUSl4FhvFQdrvw/0OCbHuoSa54F2NacLVTJxEeKH3qmo100jCkc1jLr/2uXf1U5H792PxBkC5/X3kUU0smYmWm4xnJvXy9XtQkjtyxEbl7fZaFhFjI+jYfof4iPrTR/4liWMc+1FpCxL6UJTg+cmaDJ+YqxCDiR22S2XGxjYJKTBIqaHx9klRYMV9VEWTF3BkFLLiFSNnzx/52rPOq6mOPw7iDXEA4XxoV4U3cXVjkC8N+XiMPIC0S+IaRqL4AIZMkeiiz4pDew== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=linux.dev smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lbtS9Kcg831sCdIhPFu0ucGohn4Enumb1k5jv0h4C88=; b=hOss0l1J1oWSbYaWOFSgXQOx7vrcPvdNujep4U0jFOegEz4TqJrioNrDBAAA2id6kG/YGRWiOFfFgyg8WiXWyi/fhM8XzL7cyJix31kKYyEmGeheXV/aXzIf6M17tu90E77HaiCwbjzj8qkcXyYfRHdu0EqFS915Z9JVpz2SfSY= Received: from AS8PR04CA0051.eurprd04.prod.outlook.com (2603:10a6:20b:312::26) by DB4PR08MB9285.eurprd08.prod.outlook.com (2603:10a6:10:3f2::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.21; Fri, 27 Jan 2023 11:43:12 +0000 Received: from AM7EUR03FT039.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:312:cafe::7c) by AS8PR04CA0051.outlook.office365.com (2603:10a6:20b:312::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.22 via Frontend Transport; Fri, 27 Jan 2023 11:43:11 +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 Received: from nebula.arm.com (40.67.248.234) by AM7EUR03FT039.mail.protection.outlook.com (100.127.140.224) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6043.21 via Frontend Transport; Fri, 27 Jan 2023 11:43:10 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) 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.16; Fri, 27 Jan 2023 11:43:09 +0000 Received: from e124191.cambridge.arm.com (10.1.197.45) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Fri, 27 Jan 2023 11:43:03 +0000 From: Joey Gouly To: Andrew Jones , , CC: , Alexandru Elisei , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Suzuki K Poulose , "Thomas Huth" , Will Deacon , Zenghui Yu , , , , Subject: [RFC kvm-unit-tests 20/27] qcbor: Add QCBOR as a submodule Date: Fri, 27 Jan 2023 11:41:01 +0000 Message-ID: <20230127114108.10025-21-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230127114108.10025-1-joey.gouly@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127114108.10025-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT039:EE_|DB4PR08MB9285:EE_|AM7EUR03FT005:EE_|DB9PR08MB7560:EE_ X-MS-Office365-Filtering-Correlation-Id: 9a5577ae-3eda-4d62-58f2-08db005bb1c6 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: d+xeNnQAWapLKWYV05kexHW6PajvIVLCYWIJg/wMqKyfFcWxKH93y3BB0Tyo1+ikcezdFBrQxtM+L/aYr0Jj0OAEIoLJimUIC/FkiFCVm9TKSHhbQl5OxFW8DS5HkZb3prypEYzhCDN9QmC/ZAtHPDQ3RsmC60l1Qk2rWrKHqqSRYNXl5I1H4hch9KrJb8QHXKTkjDdllTIBy1RSV6YZ5NOPEt01zGuVvarAQwVlvNgimW3R72ZC7A69OY5Q+spzRiTUS8IR5JT89T0HdMFsWgVCjRgvJ4ImVObDTckasq9kaB9nD5o8O+yUUEZrJpz/UOrY2d1+LpmvtAhdhYfuQER8WIfzXgimOIm1H0q5HR6qYXMrcJtoxcLmi64AkEfITWKYjWBcU1MJym3QdQ+ah3kIpDDkVhsd0dNwpnMEdHA+lylKGlHleMI38A8K6ifTWXsjxMqnKggsw7EbbmMKSubn+B+A55pEtNG7drwLv0saG+DUmkYoZ9SYvNP855Fb51H/3HIROWQ4ldwLtyZ7bJ3N6fsrSv6A770K/+CZHdbkNl9nHOW+RGFR4RCH1nN35BR2GxpeUHUF8OJqTvVCrlw7DQFtVPE6sI9kRypkk9gITmxdxU34iBFoSN38WUyRzhcahZ8gGiJ9taJhRNkbvcluAfuNH9wMOhBSif4fL+EdzQcMKLq4Sjv+zrWow8ZSJf1hJix7r5GYpaN3SwniqUxTbFlOd+UdRQ2LhYEfIK82TLxBtGgpZ7If3pY9HIcYNAhR0PNJnxuKpwu33hSDCrqC+3NJShC6sjw4nKpav64l5qq85pgdM1rVW8s7/FxhRgW3nnhT0Mrr3eQVZ+hdgA== 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:(13230025)(4636009)(136003)(396003)(376002)(346002)(39860400002)(451199018)(40470700004)(46966006)(36840700001)(47076005)(40460700003)(186003)(26005)(4326008)(70206006)(70586007)(8676002)(82740400003)(8936002)(81166007)(41300700001)(7416002)(4744005)(36860700001)(44832011)(966005)(7696005)(478600001)(2906002)(2616005)(5660300002)(1076003)(40480700001)(426003)(82310400005)(316002)(356005)(110136005)(36756003)(336012)(54906003)(86362001)(36900700001)(2101003);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB4PR08MB9285 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT005.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: f5b60917-3f4c-423e-3678-08db005baa3c X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Tl0kU7o6vRBUu276gheDfT5iF3sq4Uc7J8YwX3wHEEFzpiyaon30g0Csm00lrSBiY/H2lrxHC+zGqW5dWaorn0dlSDOiCDOlWGLwJUfHyIo+GtP1ev2eSatWTU1nwBLP/fzob4G8AtycpGUlU3DKbHDajDKZM7Oah9Y0aHfL1OwgsPM702kHl1UuWIl5ZQuswsE9S1BgZgPajPbpc7WiGk5p0XcpRW1BJK1zZQoWdnDZV06PjTfQ90N/3guJTwBQckUmkiOjywVGwKQ9S7/SOFx6PqewEmVXbyMA+Wv+asF/0Ve4U9Oh3zamtANNGxMqde6A89mV1YWHuva0f6kpq55AzhWmvqGr9zxm4ZrbuKNQNoqd5s3k2bWRMWq6ubTLtSS9fWaaHqmwEo/tJVZ4Kd6CgfhkezAlf5Qzaz4ExiQY/72aGkhpEHIAHUKDK5tbnlhhjqYP1+xGQ2Yo+lQkDYwRzrglAXAhoSbzJGljyMFGojT+spH3X9/BYYvr3zU0J05ezQgvkSUOxFCONWsqKFDBg4344VbRMhz9VlGjQzkMzvNpBhj36+yNrYOTCJ2TCeiWLeJcxaEHSaB7nD2rlks2j0Gds1tB/GSaqCsJLjv3qRkE3JpOmXPoMNsLsXuenpB+5nrXRROkWIQKieMTn23wvKvGQdd7kdtDB0oqODnM9UVNhtx6zL93o+9NNUi75xUkI/OcJB2YIMBBrkx094Q5rK4cxTI+l/yN8pACwegpKuWL/Hi99zTp2MALw16TjZg9c3uvv110vyN+2V0AP7JrkwD0hO91ZBBbty45l/I= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230025)(4636009)(39860400002)(376002)(136003)(346002)(396003)(451199018)(40470700004)(36840700001)(46966006)(86362001)(8676002)(4744005)(36860700001)(5660300002)(316002)(81166007)(40460700003)(478600001)(107886003)(2906002)(1076003)(426003)(82310400005)(47076005)(26005)(70586007)(2616005)(40480700001)(336012)(70206006)(44832011)(4326008)(82740400003)(41300700001)(8936002)(36756003)(54906003)(7696005)(110136005)(186003)(966005)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2023 11:43:22.6084 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9a5577ae-3eda-4d62-58f2-08db005bb1c6 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: AM7EUR03FT005.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB7560 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034344_034603_20E7F1D9 X-CRM114-Status: GOOD ( 12.49 ) 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 From: Suzuki K Poulose Adds the library QCBOR as submodule. This will be later used for arm64 realm attestation token parsing. The repository is available at: https://github.com/laurencelundblade/QCBOR tag v1.0 Signed-off-by: Suzuki K Poulose Signed-off-by: Joey Gouly --- .gitmodules | 3 +++ lib/qcbor | 1 + 2 files changed, 4 insertions(+) create mode 100644 .gitmodules create mode 160000 lib/qcbor diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..29fdbc5d --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "lib/qcbor"] + path = lib/qcbor + url = https://github.com/laurencelundblade/QCBOR.git diff --git a/lib/qcbor b/lib/qcbor new file mode 160000 index 00000000..56b17bf9 --- /dev/null +++ b/lib/qcbor @@ -0,0 +1 @@ +Subproject commit 56b17bf9f74096774944bcac0829adcd887d391e From patchwork Fri Jan 27 11:41:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13118640 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 4474EC54EAA for ; Fri, 27 Jan 2023 12:37:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0K37TbC85iR9L7pEyQo96HWXRHH8elC6wCYs6WoX6TE=; b=RgbU/FsR+lJzuA 0a4BbDh9flvFgBGIojhmv2J/Uwq352dfxswPzkdPtc62izSgHFsAvuQGPHsNmiO+ZlEflIOzy0XZD mBL/AqiYU8xxVaGlyKjHXwCtwYeDcL2HwqBpTB9U3ABvUJ23TmJYemgVwzW665BVWiV9ic65nwpBw WkepelMT8+1BKxXIlSuB6wj+GRhgaoiZt+k89jrxKNHEiXO/k0FpG3VDINZleAVsJTf/CqqI9aSdt 0OqMfPv0KUKZHvdeEFAnH7AJKvltCnQvqJxlwmgU0IEQKlHxggwIWQoG60xHgcxrRfH6wIGv24Vsl WRk0BA4rt8zjgV1vO+Eg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNxT-00EbFv-8Y; Fri, 27 Jan 2023 12:35:56 +0000 Received: from mail-am0eur02on2047.outbound.protection.outlook.com ([40.107.247.47] helo=EUR02-AM0-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN8v-00EEaQ-VF for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:43:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IUevxZg1UcpjeMjHy2JelqYsn9dKIor7hu3sqpFhgSU=; b=F64np7L4+bDEloIPHFej39lAO0BGHOjRFa7kho6aZaq8WgygQ3x+UwmYR8wAilzbuKHS6GZbkAAZjS5ivlDvul2yhCIUN/pOstmbgVijrZPrRvGnzuHOlcl/KH8QXGqx3pQN2h5BCSfV2nJiS62zgpL9aklmfwnQD0qIhuwdpS4= Received: from DB6PR07CA0002.eurprd07.prod.outlook.com (2603:10a6:6:2d::12) by AS8PR08MB8183.eurprd08.prod.outlook.com (2603:10a6:20b:560::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23; Fri, 27 Jan 2023 11:43:26 +0000 Received: from DBAEUR03FT022.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:2d:cafe::7) by DB6PR07CA0002.outlook.office365.com (2603:10a6:6:2d::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.22 via Frontend Transport; Fri, 27 Jan 2023 11:43:26 +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 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT022.mail.protection.outlook.com (100.127.142.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.21 via Frontend Transport; Fri, 27 Jan 2023 11:43:26 +0000 Received: ("Tessian outbound 43b0faad5a68:v132"); Fri, 27 Jan 2023 11:43:26 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 328f40782be5ee90 X-CR-MTA-TID: 64aa7808 Received: from a446c2399be5.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 2356810A-096C-4C8B-9DC8-612C047184FD.1; Fri, 27 Jan 2023 11:43:19 +0000 Received: from EUR01-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id a446c2399be5.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 27 Jan 2023 11:43:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MOPePCEXhhynwWV/BAlesTuY2yvHTH57WvYqiQh8DaUfc0UHcObtA+1M/uPshV+ConiYe46kRqgfIQdz8UlUoUtDCuFenuwliSImXQYM3t4v/0IIzGhoArxwycFc+PUzxEWeppL5VApCK9rWn4Ae66GkhqABUyE+tGrypNidoruWBw7YcNO0FVE6Uvuiv8GYF0Q7WvZatDfwZSl024ATlshJkPccyWWot1Cf06kM6C82nFkpePbAGQe7rua50vd0XxGZLe1F3Jeh8bLPhX1YXRjpwnpALIFLgBuAuzlVxgwgypaHDKdYAKy8QUEJNhtXPtNrGvkYurvwzpwCfsyOmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=IUevxZg1UcpjeMjHy2JelqYsn9dKIor7hu3sqpFhgSU=; b=jQU1ahQlo4Ke6Pb2xZEZdR+BCyictohj9pUSJ/a4AF3eH1Qpv5S3d1RMNeWGu5IMMRwUmHsN5rkbRDBi73zmmY6ltXVb+lw3l/hTSCARDOlPjQ/FVNTqFis1sHz/DrUGctajxfwhQ7UvAipEFZa30oCt9ZubfrBLI3f3Mb17amCJKxbzo2BEzHiFFd8QZEx6wNIoL5lHNtcp/Ps29bSbs++H4cQqWWMwpi/GN+CcFDkzTT7mNgQdMswrjU3xaB7BUPRHYcODt2qi4ephmtPHZh5oWp19osj4pl4LbbJoYObRubhT5rx4Bn9PNllgZUrHahyN4StYhhJUaWY92TnasA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=linux.dev smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IUevxZg1UcpjeMjHy2JelqYsn9dKIor7hu3sqpFhgSU=; b=F64np7L4+bDEloIPHFej39lAO0BGHOjRFa7kho6aZaq8WgygQ3x+UwmYR8wAilzbuKHS6GZbkAAZjS5ivlDvul2yhCIUN/pOstmbgVijrZPrRvGnzuHOlcl/KH8QXGqx3pQN2h5BCSfV2nJiS62zgpL9aklmfwnQD0qIhuwdpS4= Received: from AM6PR10CA0103.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::44) by AS2PR08MB9295.eurprd08.prod.outlook.com (2603:10a6:20b:599::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23; Fri, 27 Jan 2023 11:43:16 +0000 Received: from AM7EUR03FT059.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:8c:cafe::4d) by AM6PR10CA0103.outlook.office365.com (2603:10a6:209:8c::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23 via Frontend Transport; Fri, 27 Jan 2023 11:43:16 +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 Received: from nebula.arm.com (40.67.248.234) by AM7EUR03FT059.mail.protection.outlook.com (100.127.140.215) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6043.22 via Frontend Transport; Fri, 27 Jan 2023 11:43:15 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) 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.16; Fri, 27 Jan 2023 11:43:14 +0000 Received: from e124191.cambridge.arm.com (10.1.197.45) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Fri, 27 Jan 2023 11:43:09 +0000 From: Joey Gouly To: Andrew Jones , , CC: , Alexandru Elisei , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Suzuki K Poulose , "Thomas Huth" , Will Deacon , Zenghui Yu , , , , Subject: [RFC kvm-unit-tests 21/27] arm: Add build steps for QCBOR library Date: Fri, 27 Jan 2023 11:41:02 +0000 Message-ID: <20230127114108.10025-22-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230127114108.10025-1-joey.gouly@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127114108.10025-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT059:EE_|AS2PR08MB9295:EE_|DBAEUR03FT022:EE_|AS8PR08MB8183:EE_ X-MS-Office365-Filtering-Correlation-Id: ecf6ed8d-9917-493c-bc2d-08db005bb403 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: 6Pb/yAI+dMoySgWPV1ESXU1C2voGE4GuzhZPXTv6ithvZsU/Gtm10HiNA08QRjRA6wUyqBAFXOCL1LB4L+faNiVe/vtaW6OEkJQ2JAKBgZ2GhqisIHcHYXzQ+mrCZ7aK+VpQj0CU4mvEBO6y91YiCcDq4DbBHyGYX7/RQmOED4lnudve+LTBViSkrDmP1QioCSvmw8ZVHGwXUZ+/HvbzPUr++y6k+2cCXiP/GAvoGqPxaNwOtJ59NQE+fwoqbTuGEMHYF1BOoI8fJyJAFpVP8zmczAccPfJy9/dr7ZnTZFP3iCIDRwgsLtOstauOMy+G2HVmTllEDiKwgRHAnO8uFyVaUwYk8WkoggSqGkdip20c7CTkiLeT+mN7zyqgMNE3cEbqwQetVdwct3cbSF9+dFcIYxfGSL6AM1CBv3Jr5JHNM8j7BIwdIY/Q7pLWrooDAqpE1Nx/qYC4lFMuK/EaThGS4oPske/9kClCF7pcK7EUPPhQdiWOAJeUBPvVlRXeJHc3pwkpg3DALzf2yMo4twx4elkJ+qyToa2zGaPbky/o0i07JPT1u1GyxqHlHNg+mTq2yAy9IHsKPVZ3YaJwq/CYkjPd8TUlxveyD13aWXoU6ngN5H1EE1Xp4eH6k52J2YSP8V8U4H2DWQjT+5xePZzao2hE5wEiXhAQQ3UHwUwkre2/AVUlymtdbAYwfOgxhmEQG41v/7QjudMwMqjuQtk+kc4awzIdwJEw9H3EM6Dfygyvx7QDoUemqqYntlH3 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:(13230025)(4636009)(346002)(136003)(396003)(39860400002)(376002)(451199018)(46966006)(40470700004)(36840700001)(2906002)(44832011)(336012)(36860700001)(426003)(5660300002)(8936002)(41300700001)(7416002)(478600001)(2616005)(8676002)(26005)(4326008)(186003)(1076003)(6666004)(356005)(86362001)(40480700001)(81166007)(82740400003)(47076005)(83380400001)(40460700003)(70206006)(70586007)(7696005)(54906003)(316002)(110136005)(36756003)(82310400005)(2101003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB9295 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT022.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: ffcf11f7-c067-4ec1-9755-08db005bad9e X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: j188q54yKSBaU7RLjRjqzpF+9sWRs9dvw5s+3yd7K9TtXUBi3mZmOJUp9EnI6Re/VEqtEiNkwIgX0U3yiQ2IRsZBrTcq1dA5GJRAWMVMjsiLuyqguMHlHYETg+d3VyH3G1WgexCbeKCEdNcZQtatLGIr1S0SgjM/43PAmzfDWLsG4oOJ0FPD4mXEBkigqHxWW9WdHJnR3knnekEn1xacXqTtpAgE7hML/lTAl+rX2EbRBvtjxUis9Hr8salX9SMxDBegqtMvcMXv0UdMZ/F7KicZwlht9XvjdlYlZQ/uFUhP84kf0CK6SPKdJu4B/feLUq79XXOG9/t0ij1Bec5FLe17mfYCl5dFau5wBZlzvYyVVfXJzaQy/V9gHLiMB30uwrqjrw2hW21PG8umI6E6dF2rP2RcSrcz1rBJWyVliT3+gaf3f7oVtTfJYNsDWrsGbtYw46+Jpp4T1bg0/Gh2o2e8lmjYrTGHUiJIa/UtufPNAB8c5lSUnI7XDhsQVmY6NXf+4dp9IGF/N1S7rIt4fXDdr/RaXo5uFD90Ay4hTEO+AYroDm15UBL3f08y8256NJfuGU6jwFZDlVQQiXV//b9VwsIQP2pVoUyryF55ntQQAZsSSgeYva+P6TFqbV/wlifx9hn7Z0QgCbx66KiQTCMz3JfuwXU/NEMxpSjosn+YmHDxGon/XLSTBUN3WkZzwi4Owt2QaHeKrhH2GeUgGvpGzxP6WsPAie/XdUG+frU= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230025)(4636009)(396003)(346002)(39860400002)(376002)(136003)(451199018)(46966006)(40470700004)(36840700001)(2906002)(44832011)(36756003)(40480700001)(426003)(47076005)(54906003)(6666004)(83380400001)(110136005)(82310400005)(107886003)(7696005)(26005)(70586007)(1076003)(336012)(478600001)(2616005)(186003)(86362001)(70206006)(8676002)(316002)(81166007)(8936002)(4326008)(41300700001)(5660300002)(36860700001)(82740400003)(40460700003)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2023 11:43:26.5224 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ecf6ed8d-9917-493c-bc2d-08db005bb403 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: DBAEUR03FT022.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB8183 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034342_071953_08B57625 X-CRM114-Status: UNSURE ( 9.24 ) X-CRM114-Notice: Please train this message. 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 From: Suzuki K Poulose The QCBOR library will be used for Realm attestation. Signed-off-by: Suzuki K Poulose Signed-off-by: Joey Gouly --- arm/Makefile.arm64 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arm/Makefile.arm64 b/arm/Makefile.arm64 index 8448af36..8d450de9 100644 --- a/arm/Makefile.arm64 +++ b/arm/Makefile.arm64 @@ -9,6 +9,8 @@ ldarch = elf64-littleaarch64 arch_LDFLAGS = -pie -n arch_LDFLAGS += -z notext CFLAGS += -mstrict-align +CFLAGS += -I $(SRCDIR)/lib/qcbor/inc +CFLAGS += -DQCBOR_DISABLE_FLOAT_HW_USE -DQCBOR_DISABLE_PREFERRED_FLOAT -DUSEFULBUF_DISABLE_ALL_FLOAT mno_outline_atomics := $(call cc-option, -mno-outline-atomics, "") CFLAGS += $(mno_outline_atomics) @@ -25,6 +27,7 @@ cflatobjs += lib/arm64/processor.o cflatobjs += lib/arm64/spinlock.o cflatobjs += lib/arm64/gic-v3-its.o lib/arm64/gic-v3-its-cmd.o cflatobjs += lib/arm64/rsi.o +cflatobjs += lib/qcbor/src/qcbor_decode.o lib/qcbor/src/UsefulBuf.o OBJDIRS += lib/arm64 @@ -40,4 +43,5 @@ tests += $(TEST_DIR)/realm-sea.flat include $(SRCDIR)/$(TEST_DIR)/Makefile.common arch_clean: arm_clean - $(RM) lib/arm64/.*.d + $(RM) lib/arm64/.*.d \ + lib/qcbor/src/.*.d From patchwork Fri Jan 27 11:41:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13118647 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 DE3AAC54EAA for ; Fri, 27 Jan 2023 12:39:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=lXn/urAbyLamw3LhbF5WM02a5YrDp5t4HvT5u1tMcoE=; b=y+IT3/snGFFeoy kPfOCfONwKkbvg9PiPx0TXCJsOl1E9T5yN0fayG1VmyoVBTLMcY/6WwYu1funnENQoiYV1GStxfwJ juAEgpiBTNy5XWzKdSkr9uGl7nkPQ60ZhUgl4GWMbQtqerLwMZfNTQA7WCzvAL04AZFqzAvGMmxJb 1bvNaCwrYtEx/MoXWT7bwEJhxHH1JWPIIJ9wVhu/0lBuqSZ5fsJjKL1eEJjtSMEuOyeyCVTHhMpT4 /5nV/5ABuFJou7vKTNi3FE6auQnxfMBsUBUOo0vYH1whyFOjFD/jdyD5ksj65yZ6D0Oq2APgac6ph 6ddNWQZxofulekmrtJKA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNym-00Ec5h-MZ; Fri, 27 Jan 2023 12:37:19 +0000 Received: from mail-vi1eur05on20622.outbound.protection.outlook.com ([2a01:111:f400:7d00::622] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN8w-00EEZp-MQ for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:43:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XEWRpIx8pPCm3VGNmB1RktfHgDOJXJhOSH7ymvX+aDY=; b=QijpDHLf1S7AIRYCeP4ymRPTsGZVT1Na8po/1L+R7Kq5RJGA3tB0sExKHUL9IOkCSZ4mwp2F0edhiWtr+1g8UJqQXI4z8vf8pda+W7jw4X3447C++YrcW7f/bo4lgZ+PVuHWFen8a/jTHNLuWIYsFGJhz1YkV7c3wa08Ekb+ExM= Received: from DB6PR0601CA0021.eurprd06.prod.outlook.com (2603:10a6:4:7b::31) by DB8PR08MB5482.eurprd08.prod.outlook.com (2603:10a6:10:116::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23; Fri, 27 Jan 2023 11:43:33 +0000 Received: from DBAEUR03FT060.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:7b:cafe::6d) by DB6PR0601CA0021.outlook.office365.com (2603:10a6:4:7b::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.22 via Frontend Transport; Fri, 27 Jan 2023 11:43:33 +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 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT060.mail.protection.outlook.com (100.127.142.238) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23 via Frontend Transport; Fri, 27 Jan 2023 11:43:33 +0000 Received: ("Tessian outbound baf1b7a96f25:v132"); Fri, 27 Jan 2023 11:43:33 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 8547e39c894ce2d8 X-CR-MTA-TID: 64aa7808 Received: from 9065332d4944.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id B8A202EF-BCA2-4FEB-9FAA-F49BDF7DB5E0.1; Fri, 27 Jan 2023 11:43:27 +0000 Received: from EUR01-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 9065332d4944.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 27 Jan 2023 11:43:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nPQHEPmcjQCgOUs+rZTXzPiHo3SUgGR++eO5QktT/ulTmgqXFdN+CiMuKjgWawH3+f50UeXA4Ymx+5oGquSpalhqGWHtC1JCM4fkx5uBXhaLBKzekUSWpUu+oufWHyGz393ya56L1p4avYWMdQByOe8MJXgjxKUWoBarYbhOM/kYPHqE4mcczPzm/fCDFR/ZZlcVmYLSt3NcQ8iKf+CXl2ifDnekP1LHKP6vBBCgmPeCSsxNZdCTrK9hbI9sC+cRd+xWWt/oR2+S9efMLkB4hZ8hjmjGkzWp7ExrxnefeOOtSnXUsQ25CnpSCNAUOjpnHPlkz5ImtVRj6nVt7lMaXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XEWRpIx8pPCm3VGNmB1RktfHgDOJXJhOSH7ymvX+aDY=; b=M5Zr0Mc5g0QGEj2GE1n93mLdeal23bSPW7BaD2e+p3gLEdPt7uLX1qDudQEfCNRjOfwomxVnMUKssFSdxCkF+0NUFfc0m63mQ437RH8ZsstzvpLF/7Bnf655kOF72Z8Z8wY4Aueqc20xiZ5ve/YZGielGLfyiSxoCaxmj3t6FM9OZyW6+A+db5/zHNjkxoGKLiyIVZZNQt9DIu5+pSIU/3CCtEj0dcHTuNaodsl6+gytAYqPR5P7cp0DYKD+dvGqJVyRt3RBhkvCo3peKSnYA5PoSiMZlHxKgMnnQwu1OKXF48mxu966VYmHtOsPKg6c6Uu0tGtVfThGlHKHuMlGRQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=linux.dev smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XEWRpIx8pPCm3VGNmB1RktfHgDOJXJhOSH7ymvX+aDY=; b=QijpDHLf1S7AIRYCeP4ymRPTsGZVT1Na8po/1L+R7Kq5RJGA3tB0sExKHUL9IOkCSZ4mwp2F0edhiWtr+1g8UJqQXI4z8vf8pda+W7jw4X3447C++YrcW7f/bo4lgZ+PVuHWFen8a/jTHNLuWIYsFGJhz1YkV7c3wa08Ekb+ExM= Received: from AM6PR10CA0076.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::17) by PAVPR08MB8989.eurprd08.prod.outlook.com (2603:10a6:102:320::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23; Fri, 27 Jan 2023 11:43:23 +0000 Received: from AM7EUR03FT030.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:8c::4) by AM6PR10CA0076.outlook.office365.com (2603:10a6:209:8c::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23 via Frontend Transport; Fri, 27 Jan 2023 11:43:23 +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 Received: from nebula.arm.com (40.67.248.234) by AM7EUR03FT030.mail.protection.outlook.com (100.127.140.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6043.22 via Frontend Transport; Fri, 27 Jan 2023 11:43:23 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) 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.16; Fri, 27 Jan 2023 11:43:20 +0000 Received: from e124191.cambridge.arm.com (10.1.197.45) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Fri, 27 Jan 2023 11:43:14 +0000 From: Joey Gouly To: Andrew Jones , , CC: , Alexandru Elisei , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Suzuki K Poulose , "Thomas Huth" , Will Deacon , Zenghui Yu , , , , , Mate Toth-Pal Subject: [RFC kvm-unit-tests 22/27] arm: Add a library to verify tokens using the QCBOR library Date: Fri, 27 Jan 2023 11:41:03 +0000 Message-ID: <20230127114108.10025-23-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230127114108.10025-1-joey.gouly@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127114108.10025-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT030:EE_|PAVPR08MB8989:EE_|DBAEUR03FT060:EE_|DB8PR08MB5482:EE_ X-MS-Office365-Filtering-Correlation-Id: 332accd8-223b-4ef9-d251-08db005bb842 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: JG/SDIufOcyXoKX632Nk329OirO+5TZEUer/0rXaBQvx2yFmIfZ8gohDxp9eY16hF106C1K3tmj0cbeUyB3HKGdEPl4YAMSXGKEjvUYT9e3I1FWSRdlFXlSsmCdKlxlUVD97rQeurszgvGP3LeMwa0n0nLMgK1Jy9ROma/YPsVKHUU4+FkFWNg0phM/iDwiJvYjBHAhCDlbi7gbVXJNLyHMIPijjYYWmvrPZXS4Pqta13PMp6YEtWcuRKmD1fQGs+hiUYz+3jPK47ZjRn53KGkruvlmbHfBQDVNmthR0EzZMNMtHTGK8i1/3rj5yocPzdtYUzJVpObRBu4Ky1fU/+8MpiXeZlncUg1daXjwRYQ8eMROgvhpT2awhzyT2L/vlQOz6/4xALbEgmeg/+EMQro3K0bI0f5/nhh1S50294XV4Y6OcB+rK+ojy0+JwVty62yyvfKWh/fVkaDwcgw0PXB5zzrWbZU/0GaGF8yxwIW2IYneHT3ahWd144L7RlGzaU6WPwHvEnLKuEqsUe0IWEzVwZYm8I/zUeLaWin27X4yBpM7l3fzlVAp1G7V5c2zasYmQc1ok2slMEfYid9/0+1oH4dEmcdo703XGbAc56HcWW5GGizm22SEyQV8Q+5OWu/c2d07+a43jIWBl16a4RKdZicRjg05IQ33SWyrfJI7/34+aUpZtzRoV9KmJIYRivZpcuFLdwl1pF2bHns9gj4KFmqPm8qrjrc58xlT1wCmCNggSuKU7xe+iKnu1wqFIrTJ9dbjdO6Phtap2ci2h18T5aBMoH4DyUIRdMVosU8Y= 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:(13230025)(4636009)(346002)(376002)(396003)(136003)(39860400002)(451199018)(46966006)(40470700004)(36840700001)(336012)(8676002)(4326008)(1076003)(26005)(186003)(44832011)(40460700003)(82740400003)(316002)(7416002)(5660300002)(41300700001)(36860700001)(356005)(15974865002)(82310400005)(81166007)(86362001)(8936002)(40480700001)(47076005)(36756003)(2616005)(54906003)(110136005)(83380400001)(70206006)(70586007)(30864003)(426003)(478600001)(7696005)(15650500001)(2906002)(6666004)(2101003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAVPR08MB8989 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT060.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: d9d5f80a-5f48-4c3b-1912-08db005bb21f X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nWuTv4+9o3ml/mo9fJfV9HpGx4JKyz5JCm953lbxcDNBg5OhudeDtJmrVgmpVcKGbuSxr+9ClIlqA/HSL5kf/5wwzqXL8tWIrrYuvBfFJmMAnxcbKQpYnFh6opSrkt1BGrMBnPEtVUOvgSYtUOq73qpAkBtfROUpDmEBImUW8f01VU6wZf5ligyw58jWbUdPgBYuwTuinoj6nxc+grBZ0K505xKWa+Dms+NBV8dW8z1tHcS7eoCmWl96McbEIFgtRjzNoiLwRbXVgELTR4wQSNbbGS2dxtCk4BjIFUCFrx029Y4FlI+uENDNIWWTMVOL0GQ4lvLsQvKckUM7JL67QMdajFkpjHn57qUPh2Xw1D2MBYQLC+G8uLeyK65zNJGLns758AeRAqNQ8LVZaL7HDW0AFyr7vqpPPP9C++V/iyMzXdZQMPtdfUo860UtujCPisyY4vJ36mWFxkJvXqlh0775hMDGst+C4/AjnRdts7GwWToMNQfqF9F/23Sud1pqRPVvd2iGJO0eGGNcSnA3bGyxvwP5LbHGTa72hJbARe6qqXQ0vedr0sCJ3ylT1l2aUEY2RoaSo4KIaQvY+1UnxRq8MoZ9Pdl/hcIY7JfDGRNaw1MzA0I001EeQDvJuxoOvMAngMSn5q/Ucc770wMNJEBXqUSEm81qN5KGVlehpd1PT//Xr+HlOXJlIB7RRzfwZAR/nadakthU79kGtsxEv2It3cwtdn8963oxStPimqwd1aUi5VhAM1GJw6etalKf X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230025)(4636009)(346002)(376002)(396003)(136003)(39860400002)(451199018)(46966006)(40470700004)(36840700001)(336012)(8676002)(4326008)(1076003)(26005)(186003)(44832011)(40460700003)(82740400003)(316002)(5660300002)(41300700001)(36860700001)(15974865002)(82310400005)(81166007)(86362001)(8936002)(40480700001)(47076005)(36756003)(2616005)(54906003)(110136005)(83380400001)(70206006)(70586007)(30864003)(426003)(478600001)(7696005)(15650500001)(2906002)(6666004)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2023 11:43:33.6468 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 332accd8-223b-4ef9-d251-08db005bb842 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: DBAEUR03FT060.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB5482 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034343_016236_8556DA19 X-CRM114-Status: GOOD ( 14.25 ) 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 From: Mate Toth-Pal Add a library wrapper around the QCBOR for parsing the Arm CCA attestation tokens. Signed-off-by: Mate Toth-Pal Signed-off-by: Suzuki K Poulose Signed-off-by: Joey Gouly --- arm/Makefile.arm64 | 7 +- lib/token_verifier/attest_defines.h | 50 +++ lib/token_verifier/token_dumper.c | 158 ++++++++ lib/token_verifier/token_dumper.h | 15 + lib/token_verifier/token_verifier.c | 591 ++++++++++++++++++++++++++++ lib/token_verifier/token_verifier.h | 77 ++++ 6 files changed, 897 insertions(+), 1 deletion(-) create mode 100644 lib/token_verifier/attest_defines.h create mode 100644 lib/token_verifier/token_dumper.c create mode 100644 lib/token_verifier/token_dumper.h create mode 100644 lib/token_verifier/token_verifier.c create mode 100644 lib/token_verifier/token_verifier.h diff --git a/arm/Makefile.arm64 b/arm/Makefile.arm64 index 8d450de9..f57d0a95 100644 --- a/arm/Makefile.arm64 +++ b/arm/Makefile.arm64 @@ -11,6 +11,7 @@ arch_LDFLAGS += -z notext CFLAGS += -mstrict-align CFLAGS += -I $(SRCDIR)/lib/qcbor/inc CFLAGS += -DQCBOR_DISABLE_FLOAT_HW_USE -DQCBOR_DISABLE_PREFERRED_FLOAT -DUSEFULBUF_DISABLE_ALL_FLOAT +CFLAGS += -I $(SRCDIR)/lib/token_verifier mno_outline_atomics := $(call cc-option, -mno-outline-atomics, "") CFLAGS += $(mno_outline_atomics) @@ -28,6 +29,9 @@ cflatobjs += lib/arm64/spinlock.o cflatobjs += lib/arm64/gic-v3-its.o lib/arm64/gic-v3-its-cmd.o cflatobjs += lib/arm64/rsi.o cflatobjs += lib/qcbor/src/qcbor_decode.o lib/qcbor/src/UsefulBuf.o +cflatobjs += lib/token_verifier/token_verifier.o +cflatobjs += lib/token_verifier/token_dumper.o + OBJDIRS += lib/arm64 @@ -44,4 +48,5 @@ include $(SRCDIR)/$(TEST_DIR)/Makefile.common arch_clean: arm_clean $(RM) lib/arm64/.*.d \ - lib/qcbor/src/.*.d + lib/qcbor/src/.*.d \ + lib/token_verifier/.*.d diff --git a/lib/token_verifier/attest_defines.h b/lib/token_verifier/attest_defines.h new file mode 100644 index 00000000..daf51c5f --- /dev/null +++ b/lib/token_verifier/attest_defines.h @@ -0,0 +1,50 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2022 Arm Limited. + * All rights reserved. + */ + +#ifndef __ATTEST_DEFINES_H__ +#define __ATTEST_DEFINES_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#define TAG_COSE_SIGN1 (18) +#define TAG_CCA_TOKEN (399) + +#define CCA_PLAT_TOKEN (44234) /* 0xACCA */ +#define CCA_REALM_DELEGATED_TOKEN (44241) + +/* CCA Platform Attestation Token */ +#define CCA_PLAT_CHALLENGE (10) /* EAT nonce */ +#define CCA_PLAT_INSTANCE_ID (256) /* EAT ueid */ +#define CCA_PLAT_PROFILE (265) /* EAT profile */ +#define CCA_PLAT_SECURITY_LIFECYCLE (2395) +#define CCA_PLAT_IMPLEMENTATION_ID (2396) +#define CCA_PLAT_SW_COMPONENTS (2399) +#define CCA_PLAT_VERIFICATION_SERVICE (2400) +#define CCA_PLAT_CONFIGURATION (2401) +#define CCA_PLAT_HASH_ALGO_ID (2402) + +/* CCA Realm Delegated Attestation Token */ +#define CCA_REALM_CHALLENGE (10) /* EAT nonce */ +#define CCA_REALM_PERSONALIZATION_VALUE (44235) +#define CCA_REALM_HASH_ALGO_ID (44236) +#define CCA_REALM_PUB_KEY (44237) +#define CCA_REALM_INITIAL_MEASUREMENT (44238) +#define CCA_REALM_EXTENSIBLE_MEASUREMENTS (44239) +#define CCA_REALM_PUB_KEY_HASH_ALGO_ID (44240) + +/* Software components */ +#define CCA_SW_COMP_MEASUREMENT_VALUE (2) +#define CCA_SW_COMP_VERSION (4) +#define CCA_SW_COMP_SIGNER_ID (5) +#define CCA_SW_COMP_HASH_ALGORITHM (6) + +#ifdef __cplusplus +} +#endif + +#endif /* __ATTEST_DEFINES_H__ */ diff --git a/lib/token_verifier/token_dumper.c b/lib/token_verifier/token_dumper.c new file mode 100644 index 00000000..15f17956 --- /dev/null +++ b/lib/token_verifier/token_dumper.c @@ -0,0 +1,158 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2022 Arm Limited. + * All rights reserved. + */ + +#include +#include +#include "attest_defines.h" +#include "token_dumper.h" + +#define COLUMN_WIDTH "20" + +void print_raw_token(const char *token, size_t size) +{ + int i; + char byte; + + printf("\r\nCopy paste token to www.cbor.me\r\n"); + for (i = 0; i < size; ++i) { + byte = token[i]; + if (byte == 0) + printf("0x%#02x ", byte); + else + printf("0x%02x ", byte); + if (((i + 1) % 8) == 0) + printf("\r\n"); + } + printf("\r\n"); +} + +static void print_indent(int indent_level) +{ + int i; + + for (i = 0; i < indent_level; ++i) { + printf(" "); + } +} + +static void print_byte_string(const char *name, int index, + struct q_useful_buf_c buf) +{ + int i; + + printf("%-"COLUMN_WIDTH"s (#%d) = [", name, index); + for (i = 0; i < buf.len; ++i) { + printf("%02x", ((uint8_t *)buf.ptr)[i]); + } + printf("]\r\n"); +} + +static void print_text(const char *name, int index, struct q_useful_buf_c buf) +{ + int i; + + printf("%-"COLUMN_WIDTH"s (#%d) = \"", name, index); + for (i = 0; i < buf.len; ++i) { + printf("%c", ((uint8_t *)buf.ptr)[i]); + } + printf("\"\r\n"); +} + +static void print_claim(struct claim_t *claim, int indent_level) +{ + print_indent(indent_level); + if (claim->present) { + switch (claim->type) { + case CLAIM_INT64: + printf("%-"COLUMN_WIDTH"s (#%" PRId64 ") = %" PRId64 + "\r\n", claim->title, + claim->key, claim->int_data); + break; + case CLAIM_BOOL: + printf("%-"COLUMN_WIDTH"s (#%" PRId64 ") = %s\r\n", + claim->title, claim->key, + claim->bool_data?"true":"false"); + break; + case CLAIM_BSTR: + print_byte_string(claim->title, claim->key, + claim->buffer_data); + break; + case CLAIM_TEXT: + print_text(claim->title, claim->key, + claim->buffer_data); + break; + default: + printf("* Internal error at %s:%d.\r\n", __FILE__, + (int)__LINE__); + break; + } + } else { + printf("* Missing%s claim with key: %" PRId64 " (%s)\r\n", + claim->mandatory?" mandatory":"", + claim->key, claim->title); + } +} + +static void print_cose_sign1_wrapper(const char *token_type, + struct claim_t *cose_sign1_wrapper) +{ + printf("\r\n== %s Token cose header:\r\n", token_type); + print_claim(cose_sign1_wrapper + 0, 0); + /* Don't print wrapped token bytestring */ + print_claim(cose_sign1_wrapper + 2, 0); + printf("== End of %s Token cose header\r\n\r\n", token_type); +} + +void print_token(struct attestation_claims *claims) +{ + int i; + + print_cose_sign1_wrapper("Realm", claims->realm_cose_sign1_wrapper); + + printf("\r\n== Realm Token:\r\n"); + /* print the claims except the last one. That is printed in detail + * below. + */ + for (i = 0; i < CLAIM_COUNT_REALM_TOKEN; ++i) { + struct claim_t *claim = claims->realm_token_claims + i; + + print_claim(claim, 0); + } + + printf("%-"COLUMN_WIDTH"s (#%d)\r\n", "Realm measurements", + CCA_REALM_EXTENSIBLE_MEASUREMENTS); + for (i = 0; i < CLAIM_COUNT_REALM_EXTENSIBLE_MEASUREMENTS; ++i) { + struct claim_t *claim = claims->realm_measurement_claims + i; + + print_claim(claim, 1); + } + printf("== End of Realm Token.\r\n"); + + print_cose_sign1_wrapper("Platform", claims->plat_cose_sign1_wrapper); + + printf("\r\n== Platform Token:\r\n"); + for (i = 0; i < CLAIM_COUNT_PLATFORM_TOKEN; ++i) { + struct claim_t *claim = claims->plat_token_claims + i; + + print_claim(claim, 0); + } + printf("== End of Platform Token\r\n\r\n"); + + printf("\r\n== Platform Token SW components:\r\n"); + + for (i = 0; i < MAX_SW_COMPONENT_COUNT; ++i) { + struct sw_component_t *component = + claims->sw_component_claims + i; + + if (component->present) { + printf(" SW component #%d:\r\n", i); + for (int j = 0; j < CLAIM_COUNT_SW_COMPONENT; ++j) { + print_claim(component->claims + j, 2); + } + } + } + printf("== End of Platform Token SW components\r\n\r\n"); +} diff --git a/lib/token_verifier/token_dumper.h b/lib/token_verifier/token_dumper.h new file mode 100644 index 00000000..96cc0744 --- /dev/null +++ b/lib/token_verifier/token_dumper.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2022 Arm Limited. + * All rights reserved. + */ + +#ifndef __TOKEN_DUMPER_H__ +#define __TOKEN_DUMPER_H__ + +#include "token_verifier.h" + +void print_raw_token(const char *token, size_t size); +void print_token(struct attestation_claims *claims); + +#endif /* __TOKEN_DUMPER_H__ */ diff --git a/lib/token_verifier/token_verifier.c b/lib/token_verifier/token_verifier.c new file mode 100644 index 00000000..ba2a89f6 --- /dev/null +++ b/lib/token_verifier/token_verifier.c @@ -0,0 +1,591 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2022 Arm Limited. + * All rights reserved. + */ + +#include +#include +#include +#include +#include "attest_defines.h" +#include "token_verifier.h" +#include "token_dumper.h" + +#define SHA256_SIZE 32 +#define SHA512_SIZE 64 + +#define RETURN_ON_DECODE_ERROR(p_context) \ + do { \ + QCBORError ret; \ + ret = QCBORDecode_GetError(p_context); \ + if (ret != QCBOR_SUCCESS) { \ + printf("QCBOR decode failed with error at %s:%d." \ + " err = %d\r\n", \ + __FILE__, (int)__LINE__, (int)ret); \ + return TOKEN_VERIFICATION_ERR_QCBOR(ret); \ + } \ + } while (0) + +static void init_claim(struct claim_t *claim, + bool mandatory, enum claim_data_type type, + int64_t key, const char *title, bool present) +{ + claim->mandatory = mandatory; + claim->type = type; + claim->key = key; + claim->title = title; + claim->present = present; +} + +static int init_cose_wrapper_claim(struct claim_t *cose_sign1_wrapper) +{ + struct claim_t *c; + + /* The cose wrapper looks like the following: + * - Protected header (bytestring). + * - Unprotected header: might contain 0 items. This is a map. Due to + * the way this thing is implemented, it is not in the below list, + * but is handled in the verify_token_cose_sign1_wrapping + * function. + * - Payload: Platform token (bytestring). The content is passed for + * verify_platform_token. + * - Signature. + */ + c = cose_sign1_wrapper; + /* This structure is in an array, so the key is not used */ + init_claim(c++, true, CLAIM_BSTR, 0, "Protected header", false); + init_claim(c++, true, CLAIM_BSTR, 0, "Platform token payload", false); + init_claim(c++, true, CLAIM_BSTR, 0, "Signature", false); + if (c > cose_sign1_wrapper + CLAIM_COUNT_COSE_SIGN1_WRAPPER) { + return TOKEN_VERIFICATION_ERR_INIT_ERROR; + } + return 0; +} + +static int init_claims(struct attestation_claims *attest_claims) +{ + int i; + int ret; + struct claim_t *c; + /* TODO: All the buffer overwrite checks are happening too late. + * Either remove, or find a better way. + */ + c = attest_claims->realm_token_claims; + init_claim(c++, true, CLAIM_BSTR, CCA_REALM_CHALLENGE, "Realm challenge", false); + init_claim(c++, true, CLAIM_BSTR, CCA_REALM_PERSONALIZATION_VALUE, "Realm personalization value", false); + init_claim(c++, true, CLAIM_TEXT, CCA_REALM_HASH_ALGO_ID, "Realm hash algo id", false); + init_claim(c++, true, CLAIM_TEXT, CCA_REALM_PUB_KEY_HASH_ALGO_ID, "Realm public key hash algo id", false); + init_claim(c++, true, CLAIM_BSTR, CCA_REALM_PUB_KEY, "Realm signing public key", false); + init_claim(c++, true, CLAIM_BSTR, CCA_REALM_INITIAL_MEASUREMENT, "Realm initial measurement", false); + /* Realm extensible measurements are not present here as they are + * encoded as a CBOR array, and it is handled specially in + * verify_realm_token(). + */ + if (c > attest_claims->realm_token_claims + CLAIM_COUNT_REALM_TOKEN) { + return TOKEN_VERIFICATION_ERR_INIT_ERROR; + } + + ret = init_cose_wrapper_claim(attest_claims->realm_cose_sign1_wrapper); + if (ret != 0) { + return ret; + } + ret = init_cose_wrapper_claim(attest_claims->plat_cose_sign1_wrapper); + if (ret != 0) { + return ret; + } + + c = attest_claims->plat_token_claims; + init_claim(c++, true, CLAIM_BSTR, CCA_PLAT_CHALLENGE, "Challenge", false); + init_claim(c++, false, CLAIM_TEXT, CCA_PLAT_VERIFICATION_SERVICE, "Verification service", false); + init_claim(c++, true, CLAIM_TEXT, CCA_PLAT_PROFILE, "Profile", false); + init_claim(c++, true, CLAIM_BSTR, CCA_PLAT_INSTANCE_ID, "Instance ID", false); + init_claim(c++, true, CLAIM_BSTR, CCA_PLAT_IMPLEMENTATION_ID, "Implementation ID", false); + init_claim(c++, true, CLAIM_INT64, CCA_PLAT_SECURITY_LIFECYCLE, "Lifecycle", false); + init_claim(c++, true, CLAIM_BSTR, CCA_PLAT_CONFIGURATION, "Configuration", false); + init_claim(c++, true, CLAIM_TEXT, CCA_PLAT_HASH_ALGO_ID, "Platform hash algo", false); + if (c > attest_claims->plat_token_claims + + CLAIM_COUNT_PLATFORM_TOKEN) { + return TOKEN_VERIFICATION_ERR_INIT_ERROR; + } + + for (i = 0; i < CLAIM_COUNT_REALM_EXTENSIBLE_MEASUREMENTS; ++i) { + c = attest_claims->realm_measurement_claims + i; + init_claim(c, true, CLAIM_BSTR, i, + "Realm extensible measurements", false); + } + + for (i = 0; i < MAX_SW_COMPONENT_COUNT; ++i) { + struct sw_component_t *component = + attest_claims->sw_component_claims + i; + + component->present = false; + c = component->claims; + init_claim(c++, false, CLAIM_TEXT, CCA_SW_COMP_HASH_ALGORITHM, "Hash algo.", false); + init_claim(c++, true, CLAIM_BSTR, CCA_SW_COMP_MEASUREMENT_VALUE, "Meas. val.", false); + init_claim(c++, false, CLAIM_TEXT, CCA_SW_COMP_VERSION, "Version", false); + init_claim(c++, true, CLAIM_BSTR, CCA_SW_COMP_SIGNER_ID, "Signer ID", false); + if (c > component->claims + CLAIM_COUNT_SW_COMPONENT) { + return TOKEN_VERIFICATION_ERR_INIT_ERROR; + } + } + return TOKEN_VERIFICATION_ERR_SUCCESS; +} + +static int handle_claim_decode_error(const struct claim_t *claim, + QCBORError err) +{ + if (err == QCBOR_ERR_LABEL_NOT_FOUND) { + if (claim->mandatory) { + printf("Mandatory claim with key %" PRId64 " (%s) is " + "missing from token.\r\n", claim->key, + claim->title); + return TOKEN_VERIFICATION_ERR_MISSING_MANDATORY_CLAIM; + } + } else { + printf("Decode failed with error at %s:%d. err = %d key = %" + PRId64 " (%s).\r\n", __FILE__, (int)__LINE__, err, + claim->key, claim->title); + return TOKEN_VERIFICATION_ERR_QCBOR(err); + } + return TOKEN_VERIFICATION_ERR_SUCCESS; +} + +/* Consume claims from a map. + * + * This function iterates on the array 'claims', and looks up items with the + * specified keys. If a claim flagged as mandatory is not found, an error is + * returned. The function doesn't checks for extra items. So if the map contains + * items with keys that are not in the claims array, no error is reported. + * + * The map needs to be 'entered' before calling this function, and be 'exited' + * after it returns. + */ +static int get_claims_from_map(QCBORDecodeContext *p_context, + struct claim_t *claims, + size_t num_of_claims) +{ + QCBORError err; + int token_verification_error; + int i; + + for (i = 0; i < num_of_claims; ++i) { + struct claim_t *claim = claims + i; + + switch (claim->type) { + case CLAIM_INT64: + QCBORDecode_GetInt64InMapN(p_context, claim->key, + &(claim->int_data)); + break; + case CLAIM_BOOL: + QCBORDecode_GetBoolInMapN(p_context, claim->key, + &(claim->bool_data)); + break; + case CLAIM_BSTR: + QCBORDecode_GetByteStringInMapN(p_context, claim->key, + &(claim->buffer_data)); + break; + case CLAIM_TEXT: + QCBORDecode_GetTextStringInMapN(p_context, claim->key, + &(claim->buffer_data)); + break; + default: + printf("Internal error at %s:%d.\r\n", + __FILE__, (int)__LINE__); + return TOKEN_VERIFICATION_ERR_INTERNAL_ERROR; + } + err = QCBORDecode_GetAndResetError(p_context); + if (err == QCBOR_SUCCESS) { + claim->present = true; + } else { + token_verification_error = + handle_claim_decode_error(claim, err); + if (token_verification_error != + TOKEN_VERIFICATION_ERR_SUCCESS) { + return token_verification_error; + } + } + } + return TOKEN_VERIFICATION_ERR_SUCCESS; +} + +/* Consume a single claim from an array and from the top level. + * + * The claim's 'key' and 'mandatory' attribute is not used in this function. + * The claim is considered mandatory. + */ +static int get_claim(QCBORDecodeContext *p_context, struct claim_t *claim) +{ + QCBORError err; + + switch (claim->type) { + case CLAIM_INT64: + QCBORDecode_GetInt64(p_context, &(claim->int_data)); + break; + case CLAIM_BOOL: + QCBORDecode_GetBool(p_context, &(claim->bool_data)); + break; + case CLAIM_BSTR: + QCBORDecode_GetByteString(p_context, &(claim->buffer_data)); + break; + case CLAIM_TEXT: + QCBORDecode_GetTextString(p_context, &(claim->buffer_data)); + break; + default: + printf("Internal error at %s:%d.\r\n", + __FILE__, (int)__LINE__); + break; + } + err = QCBORDecode_GetAndResetError(p_context); + if (err == QCBOR_SUCCESS) { + claim->present = true; + return TOKEN_VERIFICATION_ERR_SUCCESS; + } + printf("Decode failed with error at %s:%d. err = %d claim: \"%s\".\r\n", + __FILE__, (int)__LINE__, err, claim->title); + return TOKEN_VERIFICATION_ERR_QCBOR(err); +} + +/* Consume claims from an array and from the top level. + * + * This function iterates on the array 'claims', and gets an item for each + * element. If the array or the cbor runs out of elements before reaching the + * end of the 'claims' array, then error is returned. + * + * The claim's 'key' and 'mandatory' attribute is not used in this function. + * All the elements considered mandatory. + */ +static int get_claims(QCBORDecodeContext *p_context, struct claim_t *claims, + size_t num_of_claims) +{ + QCBORError err; + int i; + + for (i = 0; i < num_of_claims; ++i) { + struct claim_t *claim = claims + i; + + err = get_claim(p_context, claim); + if (err != TOKEN_VERIFICATION_ERR_SUCCESS) { + return err; + } + } + return TOKEN_VERIFICATION_ERR_SUCCESS; +} + +static int verify_platform_token(struct q_useful_buf_c buf, + struct attestation_claims *attest_claims) +{ + QCBORDecodeContext context; + int err; + int label, index; + + QCBORDecode_Init(&context, buf, QCBOR_DECODE_MODE_NORMAL); + RETURN_ON_DECODE_ERROR(&context); + + QCBORDecode_EnterMap(&context, NULL); + RETURN_ON_DECODE_ERROR(&context); + + err = get_claims_from_map(&context, + attest_claims->plat_token_claims, + CLAIM_COUNT_PLATFORM_TOKEN); + if (err != TOKEN_VERIFICATION_ERR_SUCCESS) { + return err; + } + + label = CCA_PLAT_SW_COMPONENTS; + QCBORDecode_EnterArrayFromMapN(&context, label); + RETURN_ON_DECODE_ERROR(&context); + + index = 0; + while (1) { + QCBORDecode_EnterMap(&context, NULL); + if (QCBORDecode_GetError(&context) == QCBOR_ERR_NO_MORE_ITEMS) { + /* This is OK. We just reached the end of the array. + * Break from the loop. + */ + break; + } + + if (index >= MAX_SW_COMPONENT_COUNT) { + printf("Not enough slots in sw_component_claims.\r\n"); + printf("Increase MAX_SW_COMPONENT_COUNT in %s.\r\n", + __FILE__); + return TOKEN_VERIFICATION_ERR_INTERNAL_ERROR; + } + + err = get_claims_from_map(&context, + attest_claims->sw_component_claims[index].claims, + CLAIM_COUNT_SW_COMPONENT); + if (err != TOKEN_VERIFICATION_ERR_SUCCESS) { + return err; + } + attest_claims->sw_component_claims[index].present = true; + + QCBORDecode_ExitMap(&context); + RETURN_ON_DECODE_ERROR(&context); + + ++index; + } + /* We only get here if the decode error code was a + * QCBOR_ERR_NO_MORE_ITEMS which is expected when the end of an array is + * reached. In this case the processing must be continued, so clear the + * error. + */ + QCBORDecode_GetAndResetError(&context); + RETURN_ON_DECODE_ERROR(&context); + + QCBORDecode_ExitArray(&context); + RETURN_ON_DECODE_ERROR(&context); + + QCBORDecode_ExitMap(&context); + RETURN_ON_DECODE_ERROR(&context); + + QCBORDecode_Finish(&context); + + return TOKEN_VERIFICATION_ERR_SUCCESS; +} + +static bool verify_length_of_measurement(size_t len) +{ + size_t allowed_lengths[] = {SHA256_SIZE, SHA512_SIZE}; + int i; + + for (i = 0; i < ARRAY_SIZE(allowed_lengths); ++i) { + if (len == allowed_lengths[i]) + return true; + } + + return false; +} + +static int verify_realm_token(struct q_useful_buf_c buf, + struct attestation_claims *attest_claims) +{ + QCBORDecodeContext context; + int err; + int i; + + QCBORDecode_Init(&context, buf, QCBOR_DECODE_MODE_NORMAL); + RETURN_ON_DECODE_ERROR(&context); + + QCBORDecode_EnterMap(&context, NULL); + RETURN_ON_DECODE_ERROR(&context); + + err = get_claims_from_map(&context, attest_claims->realm_token_claims, + CLAIM_COUNT_REALM_TOKEN); + if (err != TOKEN_VERIFICATION_ERR_SUCCESS) { + return err; + } + + /* Now get the realm extensible measurements */ + QCBORDecode_EnterArrayFromMapN(&context, + CCA_REALM_EXTENSIBLE_MEASUREMENTS); + RETURN_ON_DECODE_ERROR(&context); + + err = get_claims(&context, + attest_claims->realm_measurement_claims, + CLAIM_COUNT_REALM_EXTENSIBLE_MEASUREMENTS); + if (err != TOKEN_VERIFICATION_ERR_SUCCESS) { + return err; + } + + for (i = 0; i < CLAIM_COUNT_REALM_EXTENSIBLE_MEASUREMENTS; ++i) { + struct claim_t *claims = + attest_claims->realm_measurement_claims; + struct q_useful_buf_c buf = claims[i].buffer_data; + + if (!verify_length_of_measurement(buf.len)) { + return TOKEN_VERIFICATION_ERR_INVALID_CLAIM_LEN; + } + } + + QCBORDecode_ExitArray(&context); + RETURN_ON_DECODE_ERROR(&context); + + QCBORDecode_ExitMap(&context); + QCBORDecode_Finish(&context); + + return TOKEN_VERIFICATION_ERR_SUCCESS; +} + +/* Returns a pointer to the wrapped token in: 'token_payload'. + * Returns the claims in the wrapper in cose_sign1_wrapper. + */ +static int verify_token_cose_sign1_wrapping( + struct q_useful_buf_c token, + struct q_useful_buf_c *token_payload, + struct claim_t *cose_sign1_wrapper) +{ + QCBORDecodeContext context; + QCBORItem item; + int err; + + QCBORDecode_Init(&context, token, QCBOR_DECODE_MODE_NORMAL); + RETURN_ON_DECODE_ERROR(&context); + + /* Check COSE tag. */ + QCBORDecode_PeekNext(&context, &item); + if (!QCBORDecode_IsTagged(&context, &item, + TAG_COSE_SIGN1)) { + return TOKEN_VERIFICATION_ERR_INVALID_COSE_TAG; + } + + QCBORDecode_EnterArray(&context, NULL); + RETURN_ON_DECODE_ERROR(&context); + + /* Protected header */ + err = get_claim(&context, cose_sign1_wrapper); + if (err != TOKEN_VERIFICATION_ERR_SUCCESS) { + return err; + } + + /* Unprotected header. The map is always present, but may contain 0 + * items. + */ + QCBORDecode_EnterMap(&context, NULL); + RETURN_ON_DECODE_ERROR(&context); + + /* Skip the content for now. */ + + QCBORDecode_ExitMap(&context); + RETURN_ON_DECODE_ERROR(&context); + + /* Payload */ + err = get_claim(&context, cose_sign1_wrapper + 1); + if (err != TOKEN_VERIFICATION_ERR_SUCCESS) { + return err; + } + + /* Signature */ + err = get_claim(&context, cose_sign1_wrapper + 2); + if (err != TOKEN_VERIFICATION_ERR_SUCCESS) { + return err; + } + + QCBORDecode_ExitArray(&context); + RETURN_ON_DECODE_ERROR(&context); + + *token_payload = cose_sign1_wrapper[1].buffer_data; + + return TOKEN_VERIFICATION_ERR_SUCCESS; +} + +static int verify_cca_token(struct q_useful_buf_c token, + struct q_useful_buf_c *platform_token, + struct q_useful_buf_c *realm_token) +{ + QCBORDecodeContext context; + QCBORItem item; + QCBORError err; + + QCBORDecode_Init(&context, token, QCBOR_DECODE_MODE_NORMAL); + RETURN_ON_DECODE_ERROR(&context); + + /* ================== Check CCA_TOKEN tag =========================== */ + QCBORDecode_PeekNext(&context, &item); + if (!QCBORDecode_IsTagged(&context, &item, TAG_CCA_TOKEN)) { + return TOKEN_VERIFICATION_ERR_INVALID_COSE_TAG; + } + + /* ================== Get the the platform token ==================== */ + QCBORDecode_EnterMap(&context, NULL); + RETURN_ON_DECODE_ERROR(&context); + + /* + * First element is the CCA platfrom token which is a + * COSE_Sign1_Tagged object. It has byte stream wrapper. + */ + QCBORDecode_GetByteStringInMapN(&context, CCA_PLAT_TOKEN, + platform_token); + RETURN_ON_DECODE_ERROR(&context); + + /* ================== Get the the realm token ======================= */ + /* + * Second element is the delegated realm token which is a + * COSE_Sign1_Tagged object. It has byte stream wrapper. + */ + QCBORDecode_GetByteStringInMapN(&context, CCA_REALM_DELEGATED_TOKEN, + realm_token); + RETURN_ON_DECODE_ERROR(&context); + + QCBORDecode_ExitMap(&context); + RETURN_ON_DECODE_ERROR(&context); + + /* Finishing up the decoding of the top-level wrapper */ + err = QCBORDecode_Finish(&context); + if (err != QCBOR_SUCCESS) { + printf("QCBOR decode failed with error at %s:%d. err = %d\r\n", + __FILE__, (int)__LINE__, (int)err); + return TOKEN_VERIFICATION_ERR_QCBOR(err); + } + + return TOKEN_VERIFICATION_ERR_SUCCESS; +} + +/* + * This function expect two COSE_Sing1_Tagged object wrapped with a tagged map: + * + * cca-token = #6.44234(cca-token-map) ; 44234 = 0xACCA + * + * cca-platform-token = COSE_Sign1_Tagged + * cca-realm-delegated-token = COSE_Sign1_Tagged + * + * cca-token-map = { + * 0 => cca-platform-token + * 1 => cca-realm-delegated-token + * } + * + * COSE_Sign1_Tagged = #6.18(COSE_Sign1) + */ +int verify_token(const char *token, size_t size, + struct attestation_claims *attest_claims) +{ + /* TODO: do signature check */ + /* TODO: Add tag check on tokens */ + struct q_useful_buf_c buf = {token, size}; + int ret; + struct q_useful_buf_c realm_token; + struct q_useful_buf_c realm_token_payload; + struct q_useful_buf_c platform_token; + struct q_useful_buf_c platform_token_payload; + + ret = init_claims(attest_claims); + if (ret != TOKEN_VERIFICATION_ERR_SUCCESS) { + return ret; + } + + /* Verify top-level token map and extract the two sub-tokens */ + ret = verify_cca_token(buf, &platform_token, &realm_token); + if (ret != TOKEN_VERIFICATION_ERR_SUCCESS) { + return ret; + } + + /* Verify the COSE_Sign1 wrapper of the realm token */ + ret = verify_token_cose_sign1_wrapping(realm_token, + &realm_token_payload, + attest_claims->realm_cose_sign1_wrapper); + if (ret != TOKEN_VERIFICATION_ERR_SUCCESS) { + return ret; + } + /* Verify the payload of the realm token */ + ret = verify_realm_token(realm_token_payload, attest_claims); + if (ret != TOKEN_VERIFICATION_ERR_SUCCESS) { + return ret; + } + + /* Verify the COSE_Sign1 wrapper of the platform token */ + ret = verify_token_cose_sign1_wrapping(platform_token, + &platform_token_payload, + attest_claims->plat_cose_sign1_wrapper); + if (ret != TOKEN_VERIFICATION_ERR_SUCCESS) { + return ret; + } + /* Verify the payload of the platform token */ + ret = verify_platform_token(platform_token_payload, attest_claims); + if (ret != TOKEN_VERIFICATION_ERR_SUCCESS) { + return ret; + } + + return TOKEN_VERIFICATION_ERR_SUCCESS; +} + diff --git a/lib/token_verifier/token_verifier.h b/lib/token_verifier/token_verifier.h new file mode 100644 index 00000000..ec3ab9c9 --- /dev/null +++ b/lib/token_verifier/token_verifier.h @@ -0,0 +1,77 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2022 Arm Limited. + * All rights reserved. + */ + +#ifndef __TOKEN_VERIFIER_H__ +#define __TOKEN_VERIFIER_H__ + +#include + +#define TOKEN_VERIFICATION_ERR_SUCCESS 0 +#define TOKEN_VERIFICATION_ERR_INIT_ERROR 1 +#define TOKEN_VERIFICATION_ERR_MISSING_MANDATORY_CLAIM 2 +#define TOKEN_VERIFICATION_ERR_INVALID_COSE_TAG 3 +#define TOKEN_VERIFICATION_ERR_INVALID_CLAIM_LEN 4 +#define TOKEN_VERIFICATION_ERR_INTERNAL_ERROR 5 +#define TOKEN_VERIFICATION_ERR_QCBOR(qcbor_err) (1000 + qcbor_err) + +/* Number of realm extensible measurements (REM) */ +#define REM_COUNT 4 + +#define MAX_SW_COMPONENT_COUNT 16 + +#define CLAIM_COUNT_REALM_TOKEN 6 +#define CLAIM_COUNT_COSE_SIGN1_WRAPPER 3 +#define CLAIM_COUNT_PLATFORM_TOKEN 8 +#define CLAIM_COUNT_REALM_EXTENSIBLE_MEASUREMENTS REM_COUNT +#define CLAIM_COUNT_SW_COMPONENT 4 + +/* This tells how the data should be interpreted in the claim_t struct, and not + * necessarily is the same as the item's major type in the token. + */ +enum claim_data_type { + CLAIM_INT64, + CLAIM_BOOL, + CLAIM_BSTR, + CLAIM_TEXT, +}; + +struct claim_t { + /* 'static' */ + bool mandatory; + enum claim_data_type type; + int64_t key; + const char *title; + + /* filled during verification */ + bool present; + union { + int64_t int_data; + bool bool_data; + /* Used for text and bytestream as well */ + /* TODO: Add expected length check as well? */ + struct q_useful_buf_c buffer_data; + }; +}; + +struct sw_component_t { + bool present; + struct claim_t claims[CLAIM_COUNT_SW_COMPONENT]; +}; + +struct attestation_claims { + struct claim_t realm_cose_sign1_wrapper[CLAIM_COUNT_COSE_SIGN1_WRAPPER]; + struct claim_t realm_token_claims[CLAIM_COUNT_REALM_TOKEN]; + struct claim_t realm_measurement_claims[CLAIM_COUNT_REALM_EXTENSIBLE_MEASUREMENTS]; + struct claim_t plat_cose_sign1_wrapper[CLAIM_COUNT_COSE_SIGN1_WRAPPER]; + struct claim_t plat_token_claims[CLAIM_COUNT_PLATFORM_TOKEN]; + struct sw_component_t sw_component_claims[MAX_SW_COMPONENT_COUNT]; +}; + +/* Returns TOKEN_VERIFICATION_ERR* */ +int verify_token(const char *token, size_t size, + struct attestation_claims *attest_claims); + +#endif /* __TOKEN_VERIFIER_H__ */ From patchwork Fri Jan 27 11:41:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13118639 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 1657AC54EAA for ; Fri, 27 Jan 2023 12:35:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=XgOOeBaG+9uWdsLXNOkAy7I9PSvtf3sLxSbn35l3mnQ=; b=Rk+ipLVQhSEkbb 5rDmBi3KlqqShUqsqyz7mDEL1f8HTanLVt9vuIyffshJ+q+EL16epJEap9OX2Uq4dnKqJbl4cBbvs Qgs+bukwpFeDs8m6igIhSJHWk8WqSK8Zmxw44r6ZfnAiCbysb/IdJGfcwcqJeEc/8NhxQbqrqn+qD Tm+gjILq/NvbrGEIXbhfqDCGVrCnYGYGT0LfMBusBJOupsLJl0GLI5n4s34H4M4rNoKBag1D/nwvw HV989k0gLub+HFkExgIMNTfmRwK49HOCFellpv9RQriIIOu9PwnHviFftneQbrbVwbc3fRL/yQcvY zD9gWs0dhTxChEomsMSg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNvG-00Ea8t-JL; Fri, 27 Jan 2023 12:33:43 +0000 Received: from mail-vi1eur05on2069.outbound.protection.outlook.com ([40.107.21.69] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN8u-00EEZq-Kp for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:43:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=k3BxKu6BJE8qZ6I03nBKWIFNYzAPdRnt9qPajUqJGwM=; b=S7vhYZkRh7qtQpktPriryJ6LvUGXIAWo8r9+MFfE9uSWEoCW0czcadZgWA9vEgaCXSN+0Y+7EZDsyTdzQWVhS1RW+8LZoA+O4/GFdAf2nvI60Vm0t6OEoLO2bfufqCMnZT4D1tONfWRXejN7h2EePOxmRAreeAF8sjy8o9d1mco= Received: from DB6PR0802CA0040.eurprd08.prod.outlook.com (2603:10a6:4:a3::26) by AS8PR08MB9478.eurprd08.prod.outlook.com (2603:10a6:20b:5ed::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.22; Fri, 27 Jan 2023 11:43:35 +0000 Received: from DBAEUR03FT021.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:a3:cafe::5b) by DB6PR0802CA0040.outlook.office365.com (2603:10a6:4:a3::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33 via Frontend Transport; Fri, 27 Jan 2023 11:43:35 +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 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT021.mail.protection.outlook.com (100.127.142.184) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.21 via Frontend Transport; Fri, 27 Jan 2023 11:43:35 +0000 Received: ("Tessian outbound 3ad958cd7492:v132"); Fri, 27 Jan 2023 11:43:35 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 1d3e6b00f409edc4 X-CR-MTA-TID: 64aa7808 Received: from 131ed2a06443.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 7DCA80C0-13CF-4AE6-B5D4-D72A3EAB71AC.1; Fri, 27 Jan 2023 11:43:29 +0000 Received: from EUR03-DBA-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 131ed2a06443.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 27 Jan 2023 11:43:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ByFG4Nk17rGaWCblIHRcgiVJkQEgXKT8zhDsW/YZzK6QvQTUjU4+wL5sQkGgcfxij1JCLfw5T6TFwBkyO/Qd2IwO/2gKEzV7pQVVQTc42gO/tkuQAESEW6cSi3i2Yz9uCRuAw/SxEpbx1kQ8KaekoZIpAkgJJmrVVV1k6lLRRAi8IDqRflw89ZlLcusMu27Uqcn+ycFEc15xosxWqB98a/yAVWmw6kXEV9Qg3T8eAJbeHQVTrQvWF0s6+3mkSWmfLLX4wdSCS26d3So14/y/sUzt1m+omOsorU6SQr50uFKwF8N7CClZX7LkeK5yBmvoO0WllLd+0fGNwU8AKq2PTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=k3BxKu6BJE8qZ6I03nBKWIFNYzAPdRnt9qPajUqJGwM=; b=hc79aTeFD4DuoguIn2iYz/5UQ/B792J9/kaGHRc2kxG3fsYXCkAXq8U8H2p+d4lJtrYoooKz6ZA6252BEWUgrul3esX0KXCi87kzSx3i3AVy7agcBkr8BbMozfNRm2lEXE5uUc9ISd6lR+xi2fdqpKtJdrxWKb3UOejrs5kW0VbZhF/1NwhZJgxlOzrV9dGbPXakePaa0vIOBY8pMiOl98gQ47K+RzsWJUp3TAAllmvbuCJqQgw2SDTIbbD8Nk+G3rLCFnyFML66RLOAdICRlV+YxtjARqpwXD9AGJ2UZxrI7Lzyfxz4btDhKs408Xewjk6UBGE66vJ7ww7cO4703w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=linux.dev smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=k3BxKu6BJE8qZ6I03nBKWIFNYzAPdRnt9qPajUqJGwM=; b=S7vhYZkRh7qtQpktPriryJ6LvUGXIAWo8r9+MFfE9uSWEoCW0czcadZgWA9vEgaCXSN+0Y+7EZDsyTdzQWVhS1RW+8LZoA+O4/GFdAf2nvI60Vm0t6OEoLO2bfufqCMnZT4D1tONfWRXejN7h2EePOxmRAreeAF8sjy8o9d1mco= Received: from AS9PR05CA0072.eurprd05.prod.outlook.com (2603:10a6:20b:499::16) by AM9PR08MB6145.eurprd08.prod.outlook.com (2603:10a6:20b:2dd::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.21; Fri, 27 Jan 2023 11:43:27 +0000 Received: from AM7EUR03FT011.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:499:cafe::2b) by AS9PR05CA0072.outlook.office365.com (2603:10a6:20b:499::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.25 via Frontend Transport; Fri, 27 Jan 2023 11:43:27 +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 Received: from nebula.arm.com (40.67.248.234) by AM7EUR03FT011.mail.protection.outlook.com (100.127.140.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6043.22 via Frontend Transport; Fri, 27 Jan 2023 11:43:27 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) 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.16; Fri, 27 Jan 2023 11:43:26 +0000 Received: from e124191.cambridge.arm.com (10.1.197.45) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Fri, 27 Jan 2023 11:43:20 +0000 From: Joey Gouly To: Andrew Jones , , CC: , Alexandru Elisei , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Suzuki K Poulose , "Thomas Huth" , Will Deacon , Zenghui Yu , , , , Subject: [RFC kvm-unit-tests 23/27] arm: realm: add RSI interface for attestation measurements Date: Fri, 27 Jan 2023 11:41:04 +0000 Message-ID: <20230127114108.10025-24-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230127114108.10025-1-joey.gouly@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127114108.10025-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT011:EE_|AM9PR08MB6145:EE_|DBAEUR03FT021:EE_|AS8PR08MB9478:EE_ X-MS-Office365-Filtering-Correlation-Id: 628a221e-4341-4148-2ffd-08db005bb971 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: uIMHWBPkHbxsn+FyzF/JcxVx1gihl/Wr2KBG+rmbMsKaKqCFqg5YxBejF1xoFXCptctMVzbvyHahZen4knsmc2kyh7VG3Ozi1o3VZSV08+C/ylm8ZgIj6fdYis9+ddrERF69QN61rZFKzohedDe6qgaKndB1TUmPqYcO+MuZ2NpS2VSDvx04ekQA2qZOHLRukqN5AOoB6nuXpsh5rJv43u+jJAYPKox1EsDTJCKnZg0FBTGFQ8l4hyg5hXWWXd6lZy3eeSFbcGSoOqmEfPGf1DKQtIZqLqxGBhtZU51SE5K1F8aDU9Xj+jbqn0gSCRV96ZKcQCwxfBlIqgn+q5uAcBIw4HCm5HWfZRiVjpEv0p4FJDr3pQdNp/OhqcRjcB/u2UUveOPtSPKs68meMQ8R5JoRhEnQ8MONz/zNiL4SW7//5/J0IG5jawCDcKvIJAlm7LTldszx2hbO5LLSi8FL7LcXoyAsda0ElRpCExCxmuO0cvueuNvf84XPsvx9LxProE9ux8oXss8vSWy5TVNbWq2BcPrWEpyHB3QeugnpUccR0qtHDtGpd0hOxciJdZArntC6r5pEFbfZQeUNXkwoPuToxYzhWHnhjI406jRkgvG4YeF07++UF1SIKL0KDYZaFGjL2z1IUWkZCjkg+lz0bkg8ukMI2o4RVNyrwbTMbO03IcWxyhfOwMNcqE/02tW5pU07DnEX4hNK0P7jrRjXYxt2/S4l8Hu0y90EYd4fmnLvEsmBrfgJENOyw9e/8hKN 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:(13230025)(4636009)(39860400002)(136003)(396003)(346002)(376002)(451199018)(40470700004)(46966006)(36840700001)(36756003)(40480700001)(81166007)(2616005)(8676002)(44832011)(5660300002)(7416002)(8936002)(2906002)(26005)(40460700003)(86362001)(7696005)(186003)(1076003)(4326008)(6666004)(478600001)(70206006)(70586007)(82740400003)(47076005)(426003)(36860700001)(356005)(336012)(110136005)(316002)(54906003)(41300700001)(82310400005)(36900700001)(2101003);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR08MB6145 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT021.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 37468ccd-c3db-4c78-4dd5-08db005bb45c X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pk9hFx14qadzny/AFsKb2SBVw8kQWpzEqANgbrfKXYQwPZIBWh8ZVRPl5ljQz312XQ+7qfwUp6I7ZP4WwwJM9tQ+/PAWuYNgfD/ImAJObCu6eJu8glL4DmOviP2C5yDIDyjvJdSFqABWo6Een9dduirj5vRm4k8ADHgAAZK2khjxO03tOtnRLy8BsNQKgT6bbBLMhqPf7JJa8e8F94T0yoidpG1CawxDFsWaWlwRNcr2J9j8S8q1BrpeJgq3nUu9XXRkb3o/AlxaSd8PsmKlRiDKLp4NZ+76F7IerV4IuNaPlCVQtXQGRkHKuuxczoi0XAdMWZdMfTjEsWzpgJtAclBnSKBkPhiIswj33dVcUOPeanunBIy6hhh8WT7gInHzSljfRtCcW7rg6dnLegoX2LBnYmwFPuimWCZZTe1bTu3o3MvxFrEephNmwSBujBYg3PrKer/gSuI/aRFL8dbyFMKIfml/wijh4xVypSv93GS4DiYaxoSoK7xK2xuQiZ3rgjBQD9PqNY+fbekoo6G+PMmxTEGnDt3FTT/LMe/gduyy+a+Pc0mBeTakLVpl+o50Hpll8YcEADKoeKA2TGqM9MKZ5115umxGxjNVuBI77lPoa69fIB/zwMeicD/GJc7frZDlPZCFYa676bNCXEgQ6ng8eerwvSJuRyXm2JtFMbRoGVNaRx5C9CvvChw3b4OvzBVvr1NzmEY4WPfVxF3ea5aDl1a3+QbmZ0d3h4Bevcg= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230025)(4636009)(346002)(136003)(396003)(39860400002)(376002)(451199018)(36840700001)(46966006)(40470700004)(82310400005)(426003)(40480700001)(336012)(40460700003)(2906002)(5660300002)(36756003)(47076005)(44832011)(107886003)(1076003)(26005)(186003)(6666004)(70206006)(36860700001)(82740400003)(81166007)(7696005)(86362001)(8676002)(41300700001)(4326008)(70586007)(478600001)(8936002)(316002)(2616005)(110136005)(54906003)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2023 11:43:35.6283 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 628a221e-4341-4148-2ffd-08db005bb971 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: DBAEUR03FT021.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB9478 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034340_752008_9AB22B55 X-CRM114-Status: UNSURE ( 9.59 ) X-CRM114-Notice: Please train this message. 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 From: Suzuki K Poulose Add wrappers for the Attestation and measurement related RSI calls. These will be later used in the test cases Signed-off-by: Suzuki K Poulose Signed-off-by: Joey Gouly --- lib/arm64/asm/rsi.h | 7 +++++++ lib/arm64/rsi.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/lib/arm64/asm/rsi.h b/lib/arm64/asm/rsi.h index c8179341..50bab993 100644 --- a/lib/arm64/asm/rsi.h +++ b/lib/arm64/asm/rsi.h @@ -27,6 +27,13 @@ int rsi_invoke(unsigned int function_id, unsigned long arg0, struct smccc_result *result); int rsi_get_version(void); +void rsi_attest_token_init(phys_addr_t addr, unsigned long *challenge, + struct smccc_result *res); +void rsi_attest_token_continue(phys_addr_t addr, struct smccc_result *res); +void rsi_extend_measurement(unsigned int index, unsigned long size, + unsigned long *measurement, + struct smccc_result *res); +void rsi_read_measurement(unsigned int index, struct smccc_result *res); static inline bool is_realm(void) { diff --git a/lib/arm64/rsi.c b/lib/arm64/rsi.c index 08c77889..63d0620a 100644 --- a/lib/arm64/rsi.c +++ b/lib/arm64/rsi.c @@ -66,6 +66,38 @@ void arm_rsi_init(void) prot_ns_shared = (1UL << phys_mask_shift); } +void rsi_attest_token_init(phys_addr_t addr, unsigned long *challenge, + struct smccc_result *res) +{ + rsi_invoke(SMC_RSI_ATTEST_TOKEN_INIT, addr, + challenge[0], challenge[1], challenge[2], + challenge[3], challenge[4], challenge[5], + challenge[6], challenge[7], 0, 0, res); +} + +void rsi_attest_token_continue(phys_addr_t addr, struct smccc_result *res) +{ + rsi_invoke(SMC_RSI_ATTEST_TOKEN_CONTINUE, addr, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, res); +} + +void rsi_extend_measurement(unsigned int index, unsigned long size, + unsigned long *measurement, struct smccc_result *res) +{ + rsi_invoke(SMC_RSI_MEASUREMENT_EXTEND, index, size, + measurement[0], measurement[1], + measurement[2], measurement[3], + measurement[4], measurement[5], + measurement[6], measurement[7], + 0, res); +} + +void rsi_read_measurement(unsigned int index, struct smccc_result *res) +{ + rsi_invoke(SMC_RSI_MEASUREMENT_READ, index, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, res); +} + static unsigned rsi_set_addr_range_state(unsigned long start, unsigned long size, enum ripas_t state, unsigned long *top) { From patchwork Fri Jan 27 11:41:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13118650 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 96654C38142 for ; Fri, 27 Jan 2023 12:43:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=j00Wuvhc6X8BcJyb8lOhzwCTbk8Dn8XhT4HabwsAhcs=; b=PKUYnWoJdyGrfP IKL1vA0ZEg3kR2FteaOEF11pZntziADbW/0FenQaWfIylxuKI3rNUeedpaUQNoIhSwojTCkJwlMxW 6ZiJqyQ1s9IUdKLO0lyW3dLn9+e/3E03QgyS1IJEjUvTtY/R4Vs510BalbHEEQsmn1fM9iDW595vx OUMaylVkN0ABZVk9OMJXrsTXvXuY0HU6MVPTNJ0MHm1VZayLVJtKc3ZfVngPU1QSKlsnfm+xsef91 qFxJAxv60n5iISqp4AnZ2go/ew1z3CIUzNtX1CZha7LYP74xF/wLVigw5wahTvfCyHzxZLpC7f2Q3 aX2msyOva6M0yUsWGrOA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLO37-00EfVX-NX; Fri, 27 Jan 2023 12:41:47 +0000 Received: from mail-dbaeur03on2040.outbound.protection.outlook.com ([40.107.104.40] helo=EUR03-DBA-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN9F-00EEjV-61 for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:44:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PLaFr9PZgJyXyWlvzCfGtSQ5pj75jGDJirYDuCm7ASI=; b=dyuOUwHcjj+uJ/aaLGNjgVEKrEF+ygOPm9yazPHrNevEBS1W0ronX/i7r0eyJMgtFkSzOWo3Wvhe8SxyZV5TMbf4rvzXQv0U+dBVuS/xbjgLjJ3cft+W9LNDnOxjwnEtUB/szudXLJJNd8WPQyEsntmCNxnjHKQ7oSyBjudOEuc= Received: from DB6P193CA0024.EURP193.PROD.OUTLOOK.COM (2603:10a6:6:29::34) by DB9PR08MB7398.eurprd08.prod.outlook.com (2603:10a6:10:372::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.21; Fri, 27 Jan 2023 11:43:46 +0000 Received: from DBAEUR03FT040.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:29:cafe::77) by DB6P193CA0024.outlook.office365.com (2603:10a6:6:29::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.22 via Frontend Transport; Fri, 27 Jan 2023 11:43:46 +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 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT040.mail.protection.outlook.com (100.127.142.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23 via Frontend Transport; Fri, 27 Jan 2023 11:43:46 +0000 Received: ("Tessian outbound b1d3ffe56e73:v132"); Fri, 27 Jan 2023 11:43:46 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: d6f7ab49d9999772 X-CR-MTA-TID: 64aa7808 Received: from b2b793b33f45.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 0DCECF22-853B-4E1A-A060-004B8BF11125.1; Fri, 27 Jan 2023 11:43:39 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id b2b793b33f45.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 27 Jan 2023 11:43:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M78kBIdhCd7aEFQB88Y1HisZSh3zVHVxb1CRKWSMHqrIOHHPYq/4s8pbHXACCQCcfXxlGHQQfRssncR+f5N/h7qigCUJE1sVmkZ0uul4wGkZAA7sG3xHLXCXp3cvg1YBHdjECVlsKEH7vas5W4QHLplqscvr8uz3NR+tAT8X40hLwuHvb2sLzeUPqJ0YC/DQ6fwi4NfRBbPQ1jfKWsJnkSqKuP+1JqU9cml/2QVE7KGBBOtfCtAsjm3ZF5+s+FTWxNQBTy1jEa06OUCnaMR/OnRLBBnDQoiM+asceAIVa2OjNZ7nxhKpW5aEg1WMU3fY0x12SL2md+nthw0DDLUcGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=PLaFr9PZgJyXyWlvzCfGtSQ5pj75jGDJirYDuCm7ASI=; b=Mfiz/6gzm02e7PZeWXFvDAG09cODON5ydgb7iyht2C6mgHKR+TBXeT844tvY3QAhvLnqiLcqM+eEAZcGeP7/+eVc/RGVLkVS/2dN7yhQYYbDKFJgg7YyzaQ9JxslV5IbSYy7YP3ooSbv1Aa88QNEQyGvQmCr9nrat9Q2was/CtdNtxP64JoZK5VFaQQMsdvQlKrEy70ODMgVTLipcMTA4FyI1OPeDBVl3+59NVpwAwSNXaneOikeLPCLnzXONBD0LT28lIUHgwJu969eqQqISXS5orywcqXXBJZrcD0aGCa7/3Lbnvna4epF/1/jHRuYwcDc9xUQZiK7FH4nIfVftw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=linux.dev smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PLaFr9PZgJyXyWlvzCfGtSQ5pj75jGDJirYDuCm7ASI=; b=dyuOUwHcjj+uJ/aaLGNjgVEKrEF+ygOPm9yazPHrNevEBS1W0ronX/i7r0eyJMgtFkSzOWo3Wvhe8SxyZV5TMbf4rvzXQv0U+dBVuS/xbjgLjJ3cft+W9LNDnOxjwnEtUB/szudXLJJNd8WPQyEsntmCNxnjHKQ7oSyBjudOEuc= Received: from DB3PR06CA0029.eurprd06.prod.outlook.com (2603:10a6:8:1::42) by AS8PR08MB8274.eurprd08.prod.outlook.com (2603:10a6:20b:536::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23; Fri, 27 Jan 2023 11:43:32 +0000 Received: from DBAEUR03FT062.eop-EUR03.prod.protection.outlook.com (2603:10a6:8:1:cafe::91) by DB3PR06CA0029.outlook.office365.com (2603:10a6:8:1::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.22 via Frontend Transport; Fri, 27 Jan 2023 11:43:32 +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 Received: from nebula.arm.com (40.67.248.234) by DBAEUR03FT062.mail.protection.outlook.com (100.127.142.64) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6043.25 via Frontend Transport; Fri, 27 Jan 2023 11:43:32 +0000 Received: from AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Fri, 27 Jan 2023 11:43:32 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) 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.16; Fri, 27 Jan 2023 11:43:31 +0000 Received: from e124191.cambridge.arm.com (10.1.197.45) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Fri, 27 Jan 2023 11:43:26 +0000 From: Joey Gouly To: Andrew Jones , , CC: , Alexandru Elisei , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Suzuki K Poulose , "Thomas Huth" , Will Deacon , Zenghui Yu , , , , Subject: [RFC kvm-unit-tests 24/27] arm: realm: Add helpers to decode RSI return codes Date: Fri, 27 Jan 2023 11:41:05 +0000 Message-ID: <20230127114108.10025-25-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230127114108.10025-1-joey.gouly@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127114108.10025-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT062:EE_|AS8PR08MB8274:EE_|DBAEUR03FT040:EE_|DB9PR08MB7398:EE_ X-MS-Office365-Filtering-Correlation-Id: 1617d1ca-b2c5-4d9d-2d06-08db005bc01f 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: QVg5TT9odF25czJSLKRkpYcIxQv4Cd6qZYMRahjFc8VBTPM3aeNE94hqVrpbmqPZZvn8m8HabMvp9ZybUSZN4LBk3HOSGF5YxRQPjwBqJoqs/Djiny6TkIqL8YAZ+bUPctPKho+bTySKU/Su9hBr0cUqRgIoD4oWG0LtQKngaeeWXUbBD/WJDmjO5IWf8uJUqMfY8eenhTc4HdAubsat1/wmBFvFfX9L8MkGak3dt6vE4hT14wM4VOJBqhNGyKyOzzZzQm2m/JuaJeG3sHHNHbbYuYv2tq9AdDTb2UR44kvMoFRkWNVW6DJmqMqmK4eUeQmXiO4Em3vYS9hUFwxJf5tTQ1oZg/DMi8QT/CacuJDB3yru6FK9fRu8VgqV5YTav8oyDWBXmubuIKS4+v2Qj9smVEH31WxkuHbnRfQvunV+JKsnUHXswAspgGmifW1vYikUVcH0qyOVVUOsP6ei3e0yz1PAHnRrHu1K0UDm8ciikNFDN4JlqsE07vmEpZyeHjQkvVjh1TlsOL/Yx0EbRGnke5zC3U7SoNFoRDD+mtOKG+/w7Z9CA7sPTD5fgHlg1pGFle1DCgdUcfxZCNZUVBxuwaUlafuJKLMRz3b76iLH/+G8yUKmDIiFyTNdgn3xHCXQ+kBvlKN6cHkRl5fkjzjvEuodbsi22m8meLtyFvr1tfaFeBpCz8SI67nyZPxCo4YUGPkOPY97KeN9jI4XXq6vfQix/pYoaHdFe6OvX7qEFMIZET+/kGvUku6kHvQr 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:(13230025)(4636009)(376002)(136003)(346002)(39860400002)(396003)(451199018)(46966006)(40470700004)(36840700001)(41300700001)(8936002)(7416002)(6666004)(5660300002)(36860700001)(83380400001)(336012)(426003)(47076005)(40460700003)(40480700001)(82740400003)(356005)(86362001)(54906003)(316002)(82310400005)(110136005)(36756003)(7696005)(70206006)(81166007)(70586007)(8676002)(4326008)(26005)(186003)(2616005)(478600001)(1076003)(44832011)(2906002)(36900700001)(2101003);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB8274 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT040.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 27d06a6a-cd35-4002-4da9-08db005bb783 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7c9hdfxKlcgTOSnaEpnoNXlMVU0rtnsZ7HJ4HLFN3TcrtDWIZSCoNMB30PVfGhITC+AnDm0rwDh7iiqmuVtTRp/LX7x8QsvsymdIrzb5r0aIcDqMYnjOBApSK8ep/Y+r3988pUQV8t3+1ZYtKU7UhSntwX098a2pUjSeRsa55S1smFd7AZd+3MpxniZaovoQ4N8bDpTfaE5haeLyyzBjHQKIY+ISl2GV4cp0Ort4QUzML7ULf/8aGVfbSG2mSeUENFw/OrvOe47atGzBUHXjjSGPwAMqDiGvMDQtEnhMSTiCxQR7BcOzTucl/ENctrk0kIgW+aj9u/4HqitlkhSWwcjzTM3Kx5lpAMjSjeQlj5F2MT/HY4j6vNtr/1q7vZicXA6ZZ0pWV5g0dLMvUz/q7tzRfZ6/evMhVH0scsjIbwtah9YxZDApEndn4/fsErVU86BbLAVYe04IYmIu+fsQuxkW5X1VfVaJRSxyZamVEqGrbiizQjtnBc129+ATBwWOFZ7fHLciKw8c0R65+BHvQE23T3aU8B3X8KyLzaJ13vNIoCLq5pfNnOwyo3QkBBx9oLxVqv/oXOORKQ/7RpLh9Ly3YMFjLLuWiPM4GNgjWOzXu4MsBQTLqg7ulGxnLKUEZMB1xXI2L/Sh9TWNZbqEdqoChJhL6C3x1+dSW5Oh+IDSaNnx0nWURMU1HLj/6k4BMWSQ/EVhCxhZFECroE5eHzlHlzEHOXlRTISdlvbUrQw= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230025)(4636009)(346002)(376002)(136003)(39860400002)(396003)(451199018)(46966006)(36840700001)(40470700004)(47076005)(83380400001)(36860700001)(70586007)(70206006)(336012)(82740400003)(426003)(2616005)(41300700001)(4326008)(8676002)(82310400005)(5660300002)(478600001)(107886003)(86362001)(6666004)(26005)(8936002)(81166007)(186003)(316002)(40460700003)(110136005)(40480700001)(2906002)(44832011)(36756003)(7696005)(54906003)(1076003)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2023 11:43:46.8193 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1617d1ca-b2c5-4d9d-2d06-08db005bc01f 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: DBAEUR03FT040.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB7398 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034401_284058_B6A8AE11 X-CRM114-Status: GOOD ( 13.91 ) 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 From: Suzuki K Poulose RMM encodes error code and index in the result of an operation. Add helpers to decode this information for use with the attestation tests. Signed-off-by: Suzuki K Poulose Signed-off-by: Joey Gouly --- lib/arm64/asm/rsi.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/lib/arm64/asm/rsi.h b/lib/arm64/asm/rsi.h index 50bab993..1d01a929 100644 --- a/lib/arm64/asm/rsi.h +++ b/lib/arm64/asm/rsi.h @@ -16,6 +16,39 @@ extern bool rsi_present; +/* + * Logical representation of return code returned by RMM commands. + * Each failure mode of a given command should return a unique return code, so + * that the caller can use it to unambiguously identify the failure mode. To + * avoid having a very large list of enumerated values, the return code is + * composed of a status which identifies the category of the error (for example, + * an address was misaligned), and an index which disambiguates between multiple + * similar failure modes (for example, a command may take multiple addresses as + * its input; the index identifies _which_ of them was misaligned.) + */ +typedef unsigned int status_t; +typedef struct { + status_t status; + unsigned int index; +} return_code_t; + +/* + * Convenience function for creating a return_code_t. + */ +static inline return_code_t make_return_code(unsigned int status, + unsigned int index) +{ + return (return_code_t) {status, index}; +} + +/* + * Unpacks a return code. + */ +static inline return_code_t unpack_return_code(unsigned long error_code) +{ + return make_return_code(error_code & 0xff, error_code >> 8); +} + void arm_rsi_init(void); int rsi_invoke(unsigned int function_id, unsigned long arg0, From patchwork Fri Jan 27 11:41:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13118652 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 D5B5CC54EAA for ; Fri, 27 Jan 2023 12:47:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2M9S/QnlXsV7ho6y5kT1/3QR67/RCOITg4wDVdCC5Ig=; b=bHj/mNcOa9IJTK Wfl2o7KwSGHMI/xYZX/dAHSetTbnjd2hNqidhNhvQ4FtJ/03DFgJwtlRg9F4ZIf6ureIlWl9sVyvJ nn6HtT+5FdiNejc5Rf5ZiPNJJsO4WkN432SUwp4Uy4tWc9EGKQFPTgju8haEkvh9DOpQLNQH/rbNB pXCypsoO1lrweByyic4/xj8c5K9c4qgimWqd+xHi0c0iK218ThdmKysnfe/HvSk3dXFasqawCI04c EQdVv87EwgNi8/voIXjjHHJLxEN6ErUBBIqYrpQVWqB8+5ED0F+mqafyP44tFTm08yrQa3UoNF0uG t1kgr+1Q6UYyicegMhyA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLO6X-00EguJ-2E; Fri, 27 Jan 2023 12:45:20 +0000 Received: from mail-vi1eur05on2062f.outbound.protection.outlook.com ([2a01:111:f400:7d00::62f] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN9M-00EEm4-5J for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:44:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ksCkehmux0Tdf7FGzen3at/8bCCe/emq9XBTLdttDzQ=; b=NVQlYF2vkdYU+rc47z1ciTjGIkcTnkzfz4n5Ml6QWrpA7+V20nlkjbUheJZlRVjy5mICZkhBYkbpqCJmtR1f+PwVNyV9zd6waY8QzpIyJKxJRhSt1mvKMLwIC0lR5PWxt+I5MqLsOsS7DMkzmog8u7WOWRt7rCYugyKBBc2cLc8= Received: from AS9PR06CA0386.eurprd06.prod.outlook.com (2603:10a6:20b:460::33) by DBAPR08MB5847.eurprd08.prod.outlook.com (2603:10a6:10:1a0::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23; Fri, 27 Jan 2023 11:43:50 +0000 Received: from AM7EUR03FT024.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:460:cafe::84) by AS9PR06CA0386.outlook.office365.com (2603:10a6:20b:460::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23 via Frontend Transport; Fri, 27 Jan 2023 11:43:50 +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 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM7EUR03FT024.mail.protection.outlook.com (100.127.140.238) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.22 via Frontend Transport; Fri, 27 Jan 2023 11:43:50 +0000 Received: ("Tessian outbound 6e565e48ed4a:v132"); Fri, 27 Jan 2023 11:43:50 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 5d05838f867c82d3 X-CR-MTA-TID: 64aa7808 Received: from 6f39253fd576.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 5290425F-A59F-4806-BA9B-C941E5F3FDE9.1; Fri, 27 Jan 2023 11:43:43 +0000 Received: from EUR03-DBA-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 6f39253fd576.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 27 Jan 2023 11:43:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XsY2GnkrkaiYntOL5S5IGxW6kpNScr/v2EAalopY3uT0y5HKOCdm4pnyxXDzUqM3VkdixOOwyJVI+pnOh2mhcWi5v9AO7PD2VeTweo3lSk8wWSm4WBAn9+IuG8+hE4UFJKKK6xlItcg4OLbJqxjinfuZOrS48GdeC9UOFgzN6YmnEfl1eqPFduK6woS8r+MOYP+I2f+A/K3fqbYrp97NpURGxlg7i/Cx0Ry5C/l0CMoNa5GiWeZNUD7kATteBxIsYSs4+XGl5pR1rmu3/OHf24IWoNNvTos+DxGxD7MeL03bAMI6EQO27OZe3fyzQxmogQ2cvPeAl98Xe9kWjCS7kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ksCkehmux0Tdf7FGzen3at/8bCCe/emq9XBTLdttDzQ=; b=ASbSoNGAt+4CfG3cXMZpKail+28+p8i2QhPCTeagSEXuf1rhRhYN5CxljkTUcMHssOskrTTEMA1KMRv819p+AULEeH0oA5VekAodzt3K12bnxor9MuNUL4mY0EQKLVDdjUyQYfz7D3n8tf8Yb6MaOoI1DSr3dQeJED/ophXqw7tyvRU6Hgrhmki0nGmU5bF96RVtiH/RPGcX0ecS2mScqG9paZtMDfO6ae+0CoFAZHtKLXiu1LxCkScGwREesmG1DOMhuNXI5lZHt2AHMWGOhq6B0pOG3nU5cREdb8dm907uGxm3vMX4Bb8JiMTr2jYjaWliou/4YFM5Du3wE5FC0A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=linux.dev smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ksCkehmux0Tdf7FGzen3at/8bCCe/emq9XBTLdttDzQ=; b=NVQlYF2vkdYU+rc47z1ciTjGIkcTnkzfz4n5Ml6QWrpA7+V20nlkjbUheJZlRVjy5mICZkhBYkbpqCJmtR1f+PwVNyV9zd6waY8QzpIyJKxJRhSt1mvKMLwIC0lR5PWxt+I5MqLsOsS7DMkzmog8u7WOWRt7rCYugyKBBc2cLc8= Received: from DUZPR01CA0047.eurprd01.prod.exchangelabs.com (2603:10a6:10:469::16) by VI1PR08MB10124.eurprd08.prod.outlook.com (2603:10a6:800:1c6::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.25; Fri, 27 Jan 2023 11:43:38 +0000 Received: from DBAEUR03FT037.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:469:cafe::d4) by DUZPR01CA0047.outlook.office365.com (2603:10a6:10:469::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.37 via Frontend Transport; Fri, 27 Jan 2023 11:43:38 +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 Received: from nebula.arm.com (40.67.248.234) by DBAEUR03FT037.mail.protection.outlook.com (100.127.142.208) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6043.23 via Frontend Transport; Fri, 27 Jan 2023 11:43:38 +0000 Received: from AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Fri, 27 Jan 2023 11:43:37 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) 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.16; Fri, 27 Jan 2023 11:43:37 +0000 Received: from e124191.cambridge.arm.com (10.1.197.45) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Fri, 27 Jan 2023 11:43:31 +0000 From: Joey Gouly To: Andrew Jones , , CC: , Alexandru Elisei , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Suzuki K Poulose , "Thomas Huth" , Will Deacon , Zenghui Yu , , , , , Mate Toth-Pal Subject: [RFC kvm-unit-tests 25/27] arm: realm: Add Realm attestation tests Date: Fri, 27 Jan 2023 11:41:06 +0000 Message-ID: <20230127114108.10025-26-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230127114108.10025-1-joey.gouly@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127114108.10025-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT037:EE_|VI1PR08MB10124:EE_|AM7EUR03FT024:EE_|DBAPR08MB5847:EE_ X-MS-Office365-Filtering-Correlation-Id: 04dbb501-cb31-4336-6124-08db005bc24a 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: lgsspNkfJ1FnkQc5doCWVVijMA7Vko9KhNOVkYguOIs07HyTIfme9VtMKvoex904pudIl0l92v2iPCuOJJ/Jp2uonaJOepNJECGIlIW3Ku7yIeHn8G//UJYSkiPxcLChqH9lc9FmJUPC/6NLa3BEpkinQYPqx9qsMEjEpJd/aSV7NnXo2gUivqoRrtJJ8cUnA0i/Z/wSazV+h+ixna/16nK60gJmDiipekEK/fizvFsZmQecFHt1BigVbAD4wDvAy2mk20VFVcvs0koChhYD6+gAvOb2Iyw4Edv46xyvJVSdn+ShaBQ9atOPxsXbkdLg6rf6DPtYnUtKXC/nfPE7jkE+1I1Cdn6PDhOsHGMt4JFU7vIOwerVCM4DsFhnNPMw7/dJSaY2TvZYxIT+h0nSYaGodD/shKyvOtkgEExfPkVtgDGELXPJ0OVtGtFnF1/c3+AuthVtTbLvN7j1S1H/xsbYxSNTjDiOL4wCeI2jnoSCOAUORoVRfU2DrYemUGjVKbNOfFOwU0/qUnBYGL/SRYg9V+Yj4yEj6+65Dpfx3b/mxHobAW1tPHTUKtt6kgu94Fa95/YKauuPCOwN0ZHwywI0wVahBJzEBj++CmwluavHNigya1U+6UKQAwRbQjXDpMXhDs+5MgfX8roRUuXjyQH9mijKOBCU4mXQjuXYEx5nD5DzXdp/AptkE50rbdijA4vs86D97euHXXgIKhorK2rOsloLhV3Gc0ZIyi8gwmhvYlulp8/VKHONR75Fm8etExQRXauNAenKcoY7SCg66maWQvQ43LlY1MQcpgGpFPc= 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:(13230025)(4636009)(39860400002)(346002)(376002)(396003)(136003)(451199018)(36840700001)(46966006)(40470700004)(41300700001)(426003)(86362001)(40460700003)(7696005)(47076005)(82310400005)(36756003)(1076003)(70586007)(6666004)(54906003)(81166007)(8936002)(83380400001)(36860700001)(2906002)(7416002)(5660300002)(30864003)(82740400003)(356005)(40480700001)(44832011)(336012)(316002)(186003)(966005)(70206006)(8676002)(4326008)(26005)(2616005)(110136005)(478600001)(2101003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB10124 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT024.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: c6125aa0-8690-4fb4-5d70-08db005bbb12 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uoQkaykUcdBaZ6k/Q8E7yI+AkR/LwyF42fiHKuov4tyErgaQfq5H3FrO4maviT2D/bXTXzxENnqZ6AijDbfhtVVP6J4CW+DyxteW5nVphcOjm4jOjFxwYREVG/VsDV1m+MB3XC9LCQdvSZQ4M2uYS6SAfSofYxnRtmfEaotfFqOMT4jRPuem2sm1UxDQnebMLV4/aY8MjrBPXYOg5RjIOAsZy+6B7NOsmR/6yTq4I0dCvxo1fpAKeVO2Oa7UnWm3x7wvLAUQ0V7OpGedzr/jlnrgktw1e0l+2kvWxhu26XMjoZLw0YtonLP3w/2flplLCJIf3Ys4FcA+2rC73HKpD8cfTJSj4NLVBUy8DCf2uKZ0TaUHfuQAQIfOhdkKxTH9SK80BbMXa/EacMjq3TyUsTtq7+Zaksrv85vjgA5IPdujAFaSggPRQ7xXLgcHDnOkX4pQRGVtPhbNzdJQZnMDvK3RycE1djH5+qpHMqlF8qavEfUPGBM9/y2t+ZC4z1i1+UKJHBNaXbN4XiKR7GCTfMjkHSIfRFeH1MTprhaIOET8fFpF7HKJOWUIT9gfafkk2yJoSBMzt6szKrLENGCJEO/rDPFusTjMvB6SMvsARpEjZPSgP2prR1kUWaPDmTfvBNuH2CJGd3DOcSuDMq5KgPRRPlJizeJ/jv6ca+zQbSh3cM9py+YZdF54zdkC9AxFN4Kki0rtK8rBGDacL4VXIAwOiKXiu2NrqULmnsi+E3sKpxTYfYUWmDEBgcrx7erW X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230025)(4636009)(346002)(39860400002)(376002)(136003)(396003)(451199018)(36840700001)(40470700004)(46966006)(83380400001)(41300700001)(86362001)(2616005)(110136005)(54906003)(82310400005)(36756003)(336012)(316002)(478600001)(966005)(7696005)(26005)(186003)(40460700003)(6666004)(1076003)(4326008)(426003)(8676002)(70586007)(47076005)(70206006)(2906002)(81166007)(8936002)(40480700001)(44832011)(30864003)(5660300002)(82740400003)(36860700001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2023 11:43:50.3954 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 04dbb501-cb31-4336-6124-08db005bc24a 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: AM7EUR03FT024.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5847 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034408_619359_B8063E1A X-CRM114-Status: GOOD ( 15.63 ) 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 From: Mate Toth-Pal Add tests for Attestation and measurement related RSI calls. Signed-off-by: Mate Toth-Pal Co-developed-by: Suzuki K Poulose [ Rewrote the test cases, keeping the core testing data/logic ] Signed-off-by: Suzuki K Poulose Signed-off-by: Joey Gouly --- arm/Makefile.arm64 | 1 + arm/realm-attest.c | 1125 ++++++++++++++++++++++++++++++++++++++++++++ arm/unittests.cfg | 50 ++ lib/libcflat.h | 1 + 4 files changed, 1177 insertions(+) create mode 100644 arm/realm-attest.c diff --git a/arm/Makefile.arm64 b/arm/Makefile.arm64 index f57d0a95..0a0c4f2c 100644 --- a/arm/Makefile.arm64 +++ b/arm/Makefile.arm64 @@ -41,6 +41,7 @@ tests += $(TEST_DIR)/micro-bench.flat tests += $(TEST_DIR)/cache.flat tests += $(TEST_DIR)/debug.flat tests += $(TEST_DIR)/realm-rsi.flat +tests += $(TEST_DIR)/realm-attest.flat tests += $(TEST_DIR)/realm-fpu.flat tests += $(TEST_DIR)/realm-sea.flat diff --git a/arm/realm-attest.c b/arm/realm-attest.c new file mode 100644 index 00000000..6c357fb5 --- /dev/null +++ b/arm/realm-attest.c @@ -0,0 +1,1125 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2022 Arm Limited. + * All rights reserved. + */ +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + + +#define SHA256_SIZE 32 + +struct challenge { + unsigned long words[8]; +}; + +struct measurement { + unsigned long words[8]; +}; + +static char __attribute__((aligned(SZ_2M))) __attribute__((section(".data"))) + block_buf_data[SZ_2M * 2]; + +static char __attribute__((aligned(SZ_2M))) __attribute__((section(".bss"))) + block_buf_bss[SZ_2M]; + +static char __attribute__((aligned(SZ_4K))) __attribute__((section(".data"))) + page_buf_data[SZ_4K]; + +static char __attribute__((aligned(SZ_4K))) __attribute__((section(".bss"))) + page_buf_bss[SZ_4K]; + +/* Page aligned offset within the block mapped buffer */ +#define BLOCK_BUF_OFFSET (SZ_8K) + +static inline void debug_print_raw_token(void *buf, size_t size) +{ +#ifdef PRINT_RAW_TOKEN + print_raw_token(buf, size); +#endif +} + +static inline void debug_print_token(struct attestation_claims *claim) +{ +#ifdef PRINT_TOKEN + print_token(claim); +#endif +} + +static bool claims_verify_token(char *token, size_t token_size, + struct attestation_claims *claims, + bool report_success) +{ + int verify_rc = verify_token(token, token_size, claims); + int cpu = smp_processor_id(); + + if (verify_rc == TOKEN_VERIFICATION_ERR_SUCCESS) { + if (report_success) + report(true, "CPU%d: Verfication of token passed", cpu); + return true; + } + + report(false, + "CPU%d: Verification of token failed with error code %d", + cpu, verify_rc); + + return false; +} + +static inline void attest_token_init(phys_addr_t addr, + struct challenge *ch, + struct smccc_result *res) +{ + rsi_attest_token_init(addr, &ch->words[0], res); +} + + +static inline void attest_token_continue(phys_addr_t addr, + struct smccc_result *res) +{ + rsi_attest_token_continue(addr, res); +} + +static inline void attest_token_complete(phys_addr_t addr, + struct smccc_result *res) +{ + do { + attest_token_continue(addr, res); + } while (res->r0 == RSI_INCOMPLETE); +} + +static void get_attest_token(phys_addr_t ipa, + struct challenge *ch, + struct smccc_result *res) +{ + attest_token_init(ipa, ch, res); + + if (res->r0) + return; + attest_token_complete(ipa, res); +} + +/* + * __get_attest_token_claims: Get attestation token and verify the claims. + * If @claims is not NULL, token is parsed and the @claims is populated. + * All failures reported. Success is only reported if the @report_success is + * true. + * Returns whether the calls and verification succeeds + */ +static bool __get_attest_token_claims(void *buf, struct challenge *ch, + struct attestation_claims *claims, + size_t *token_size, bool report_success) +{ + struct smccc_result result; + struct attestation_claims local_claims; + struct attestation_claims *claimsp; + bool rc = false; + + /* Use the local_claims if claims is not supplied */ + claimsp = claims ? : &local_claims; + + get_attest_token(virt_to_phys(buf), ch, &result); + if (result.r0) { + report(false, "Get attestation token with : %ld", result.r0); + return rc; + } + + if (report_success) + report(true, "Get attestation token"); + + /* Update token_size if necessary */ + if (token_size) + *token_size = result.r1; + + return claims_verify_token(buf, result.r1, claimsp, report_success); +} + +static bool get_attest_token_claims(void *buf, struct challenge *ch, + struct attestation_claims *claims, + size_t *token_size) +{ + return __get_attest_token_claims(buf, ch, claims, token_size, false); +} + +static void get_verify_attest_token(void *buf, struct challenge *ch, + const char *desc) +{ + report_prefix_push(desc); + __get_attest_token_claims(buf, ch, NULL, NULL, true); + report_prefix_pop(); +} + +static void get_verify_attest_token_verbose(void *buf, + struct challenge *ch, + const char *desc) +{ + size_t token_size; + struct attestation_claims claims; + + report_prefix_push(desc); + if (__get_attest_token_claims(buf, ch, &claims, &token_size, true)) { + debug_print_raw_token(buf, token_size); + debug_print_token(&claims); + } + report_prefix_pop(); +} + +static void test_get_attest_token(void) +{ + char stack_buf[SZ_4K]__attribute__((aligned(SZ_4K))); + char *heap_buf; + struct challenge ch; + + memset(&ch, 0xAB, sizeof(ch)); + + /* Heap buffer */ + heap_buf = memalign(SZ_4K, SZ_4K); + if (heap_buf) { + get_verify_attest_token(heap_buf, &ch, "heap buffer"); + free(heap_buf); + } else { + report_skip("heap buffer: Failed to allocate"); + } + + /* Stack buffer */ + get_verify_attest_token(stack_buf, &ch, "stack buffer"); + /* Page aligned buffer .data segment */ + get_verify_attest_token(page_buf_data, &ch, ".data segment buffer"); + /* Page aligned buffer .bss segment */ + get_verify_attest_token(page_buf_bss, &ch, ".bss segment buffer"); + /* Block mapped buffer in .data segment */ + get_verify_attest_token(&block_buf_data[BLOCK_BUF_OFFSET], &ch, + "block mapped .data segment buffer"); + /* Block mapped buffer in .bss segment */ + get_verify_attest_token_verbose(&block_buf_bss[BLOCK_BUF_OFFSET], + &ch, "block mapped .bss segment buffer"); +} + +static void get_attest_token_check_fail(phys_addr_t ipa, + struct challenge *ch, + return_code_t exp, + const char *buf_desc) +{ + struct smccc_result result; + return_code_t rc; + + report_prefix_push(buf_desc); + get_attest_token(ipa, ch, &result); + rc = unpack_return_code(result.r0); + if (rc.status != exp.status) { + report(false, "Get attestation token " + "got (%d) expected (%d)", + rc.status, exp.status); + } else { + report(true, "Get attestation token fails as expected"); + } + report_prefix_pop(); +} + +static void test_get_attest_token_bad_input(void) +{ + struct challenge ch; + return_code_t exp; + + memset(page_buf_data, 0, sizeof(page_buf_data)); + memset(&ch, 0xAB, sizeof(ch)); + exp = make_return_code(RSI_ERROR_INPUT, 0); + get_attest_token_check_fail(virt_to_phys(page_buf_data + 0x100), + &ch, exp, "unaligned buffer"); + get_attest_token_check_fail(__phys_end + SZ_512M, &ch, exp, + "buffer outside PAR"); +} + +static void test_get_attest_token_abi_misuse(void) +{ + struct smccc_result result; + struct challenge ch; + phys_addr_t ipa = virt_to_phys(page_buf_data); + return_code_t rc; + + memset(&ch, 0xAB, sizeof(ch)); + + /* + * Testcase 1 - Miss call to RSI_ATTEST_TOKEN_INIT + * + * step1. Execute a successful test to reset the state machine. + */ + report_prefix_push("miss token init"); + get_attest_token(ipa, &ch, &result); + if (result.r0) { + report(false, "Get attestation failed %ld", result.r0); + report_prefix_pop(); /* miss token init */ + return; + } + /* + * step2. Execute RSI_ATTEST_TOKEN_CONTINUE without an RSI_ATTEST_TOKEN_INIT. + * Expect an error == RSI_ERROR_STATE + */ + attest_token_continue(ipa, &result); + rc = unpack_return_code(result.r0); + if (rc.status != RSI_ERROR_STATE) { + report(false, "Unexpected result (%d, %d) vs (%d) expected", + rc.status, rc.index, RSI_ERROR_STATE); + report_prefix_pop(); /* miss token init */ + return; + } + + report(true, "Fails as expected"); + report_prefix_pop(); /* miss token init */ + + /* + * Test case 2 - Calling with inconsistend input. + * step1. Issue RSI_ATTEST_TOKEN_INIT + * step2. Modify the challenge and issue RSI_ATTEST_TOKEN_CONTINUE. + * Test : Expect error == (RSI_ERROR_INPUT, 0) + */ + report_prefix_push("inconsistent input"); + attest_token_init(ipa, &ch, &result); + rc = unpack_return_code(result.r0); + if (result.r0) { + report(false, "RSI_ATTEST_TOKEN_INIT failed unexpectedly (%d, %d)", + rc.status, rc.index); + report_prefix_pop(); /* inconsistent input */ + return; + } + + /* + * Corrupt the IPA address input to ATTEST_TOKEN_CONTINUE, + */ + attest_token_continue(ipa ^ 0x1UL, &result); + rc = unpack_return_code(result.r0); + if (rc.status != RSI_ERROR_INPUT) { + report(false, "Attest token continue unexpected results" + " (%d) vs expected (%d)", + rc.status, RSI_ERROR_INPUT); + } + + report_prefix_pop(); /* inconsistent input */ + + /* + * Test case 3 + * step1. Complete the token attestation from with proper values. + * Failures in the Test case 2 should not affect the completion. + */ + report_prefix_push("valid input after inconsistent input"); + attest_token_complete(ipa, &result); + rc = unpack_return_code(result.r0); + if (result.r0) { + report(false, "Attest token continue failed with (%d, %d)", + rc.status, rc.index); + return; + } else { + report(true, "Attest token continue complete"); + } + report_prefix_pop(); /* Valid input after inconsistent input */ +} + +static void test_get_attest_token_abi_abort_req(void) +{ + int i; + char *p; + size_t size; + struct attestation_claims claims; + struct smccc_result result; + struct challenge ch; + char stack_buf[SZ_4K] __attribute__((aligned(SZ_4K))) = { 0 }; + phys_addr_t addr = virt_to_phys(stack_buf); + + /* Set the initial challenge, which will be aborted */ + memset(&ch, 0xAB, sizeof(ch)); + attest_token_init(addr, &ch, &result); + if (result.r0) { + report(false, "Attest token init failed %ld", result.r0); + return; + } + + /* Execute a few cycles, but not let it complete */ + for (i = 0; i < 3; i++) { + attest_token_continue(addr, &result); + if (result.r0 != RSI_INCOMPLETE) { + if (result.r0) + report(false, "Attest token continue : unexpected " + "failure %ld", result.r0); + else + report_skip("Attest token finished at iteration %d", + i + 1); + return; + } + } + + /* Issue a fresh Attest Token request with updated challenge */ + memset(&ch, 0xEE, sizeof(ch)); + get_attest_token(addr, &ch, &result); + if (result.r0) { + report(false, "Attest Token failed %ld", result.r0); + return; + } + claims_verify_token(stack_buf, result.r1, &claims, false); + + /* + * TODO: Index of claim in the array depends on the init sequence + * in token_verifier.c: init_claim() + */ + p = (char*)claims.realm_token_claims[0].buffer_data.ptr; + size = claims.realm_token_claims[0].buffer_data.len; + + /* Verify that token contains the updated challenge. */ + if (size != sizeof(ch)) { + report(false, "Attestation token: abort request: " + "claim size mismatch : %ld", result.r0); + return; + } + if (memcmp(p, &ch, size)) { + report(false, "Attestation token: abort request: " + "claim value mismatch: %ld", result.r0); + return; + } + report(true, "Aborting ongoing request"); +} + +static void run_rsi_attest_tests(void) +{ + report_prefix_push("attest"); + + test_get_attest_token(); + + report_prefix_push("bad input"); + test_get_attest_token_bad_input(); + report_prefix_pop(); + + report_prefix_push("ABI misuse"); + test_get_attest_token_abi_misuse(); + report_prefix_pop(); + + report_prefix_push("ABI Abort"); + test_get_attest_token_abi_abort_req(); + report_prefix_pop(); + + report_prefix_pop(); /* attest */ +} + +static void run_get_token_times(void *data) +{ + char buf[SZ_4K] __attribute__((aligned(SZ_4K))); + struct challenge ch; + struct attestation_claims claims; + unsigned long runs = ((size_t)data); + int i, j; + int cpu = smp_processor_id(); + + report_info("CPU%d: Running get token test %ld times", cpu, runs); + for (i = 0; i < runs; i++) { + uint8_t pattern = (cpu << 4) | (i & 0xf); + size_t token_size; + struct claim_t *claim; + + memset(buf, 0, sizeof(buf)); + memset(&ch, pattern, sizeof(ch)); + + if (!get_attest_token_claims(buf, &ch, &claims, &token_size)) + return; + claim = claims.realm_token_claims; + if (claim->key != CCA_REALM_CHALLENGE || + claim->buffer_data.len != sizeof(ch)) { + report(false, "Invalid challenge size in parsed token:" + " %zu (expected %zu)", + claim->buffer_data.len, sizeof(ch)); + return; + } + + for (j = 0; j < sizeof(ch); j++) { + uint8_t byte = ((uint8_t *)claim->buffer_data.ptr)[j]; + if (byte != pattern) { + report(false, "Invalid byte in challenge[%d]: " + " %02x (expected %02x)", + j, byte, pattern); + return; + } + } + } + report(true, "CPU%d: Completed runs", cpu); +} + +static void run_rsi_attest_smp_test(void) +{ + unsigned long runs = 100; + + report_prefix_push("attest_smp"); + on_cpus(run_get_token_times, (void *)runs); + report_prefix_pop(); +} + +/* + * There are 7 slots for measurements. The first is reserved for initial + * content measurement. The rest are meant to store runtime measurements. + * Runtime measurements are extended (concatenated and hashed). Reading + * them back separately is unsupported. They can be queried in an + * attestation token. + * + * Measurement size is 64bytes maximum to accommodate a SHA512 hash. + */ + +static void measurement_extend(int idx, struct measurement *m, size_t size, + struct smccc_result *res) +{ + rsi_extend_measurement(idx, size, &m->words[0], res); +} + +static void test_extend_measurement(void) +{ + struct smccc_result result; + struct measurement m; + return_code_t rc; + int idx; + + memset(&m, 0xEE, sizeof(m)); + /* + * Store Runtime measurements for all possible slots. + */ + for (idx = 1; idx <= REM_COUNT; idx ++) { + measurement_extend(idx, &m, sizeof(m.words), &result); + rc = unpack_return_code(result.r0); + report(!rc.status, "Extend measurement idx: %d (%d, %d)", + idx, rc.status, rc.index); + } +} + +static void test_extend_measurement_bad_index(struct measurement *m) +{ + struct smccc_result result; + return_code_t rc; + int indices[] = { 0, REM_COUNT + 1 }; + const char *idx_descs[] = { "reserved", "out-of-bounds" }; + int i; + + report_prefix_push("index"); + for (i = 0; i < ARRAY_SIZE(indices); i++) { + report_prefix_push(idx_descs[i]); + measurement_extend(indices[i], m, sizeof(m->words), &result); + rc = unpack_return_code(result.r0); + + if (rc.status != RSI_ERROR_INPUT) + report(false, "Extend measurement index: " + "actual (%d) vs expected (%d)", + rc.status, RSI_ERROR_INPUT); + else + report(true, "Extend measurement index fails as expected"); + report_prefix_pop(); /* idx_descs[i] */ + } + report_prefix_pop(); /* index */ +} + +static void test_extend_measurement_bad_size(struct measurement *m) +{ + struct smccc_result result; + return_code_t rc; + + report_prefix_push("size"); + rsi_extend_measurement(1, 65, &m->words[0], &result); + rc = unpack_return_code(result.r0); + if (rc.status != RSI_ERROR_INPUT) + report(false, "Measurement extend " + "actual (%d) vs expected (%d)", + rc.status, RSI_ERROR_INPUT); + else + report(true, "Extend measurement fails as expected"); + report_prefix_pop(); /* size */ +} + +static void test_extend_measurement_bad_input(void) +{ + struct measurement m; + + report_prefix_push("bad input"); + memset(&m, 0xEE, sizeof(m)); + test_extend_measurement_bad_index(&m); + test_extend_measurement_bad_size(&m); + report_prefix_pop(); /* bad input */ +} + +static void run_rsi_extend_tests(void) +{ + report_prefix_push("extend"); + test_extend_measurement(); + test_extend_measurement_bad_input(); + report_prefix_pop(); /* extend */ +} + +/* + * cpu_extend_run - Parameters for the extend measurement SMP run. + * @idx - Pointer to the index + * @size - Size of the measurement data + * @m - Measurement data. + */ +struct cpu_extend_run { + int *idx; + struct measurement *m; + size_t size; + unsigned long rc; +}; + +/* + * We get an array of the parameters for the extend measurement. + * The cpu number is the index to the array. At the moment we + * only support 2 cpus. + */ +static void cpu_run_extend_measurement(void *data) +{ + struct smccc_result result; + struct cpu_extend_run *run; + int me = smp_processor_id(); + + assert(me >= 0); + + /* Tests for only 2 CPUs */ + if (me > 1) + return; + run = (struct cpu_extend_run *)data + me; + rsi_extend_measurement(*run->idx, run->size, &run->m->words[0], &result); + run->rc = result.r0; + if (result.r0 != 0) + report(false, "CPU%d: Extend measurement failed for slot %d", + me, *run->idx); +} + +static bool claims_uses_sha256_algo(struct attestation_claims *claims) +{ + struct claim_t *claim = claims->realm_token_claims + 2; /* CCA_REALM_HASH_ALGO_ID */ + + /* claim->buffer_data.ptr: Not NULL terminated, so using memcmp */ + return !memcmp(claim->buffer_data.ptr, "sha-256", strlen("sha-256")); +} + +static void test_rsi_extend_smp(void) +{ + int slot, m_idx; + struct measurement m[2]; + struct challenge ch; + struct attestation_claims claims; + size_t token_size; + + /* + * Measurements to extend with + * + * Run CPU0 data CPU1 data + * 1: [31 - 0] [55 - 24] + * 2: [39 - 8] [63 - 32] + * 3: [47 - 16] [71 - 40] + */ + char measure_bytes[] = { + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27 + }; + + /* + * The expected measurement values. Each element in the array contains + * a possible extended measurement value. (Multiple values are possible + * as the extend function might be called in any order by the cores.) + * The array contains results for all the possible orders. The number of + * possibilities can be calculated as here: + * https://math.stackexchange.com/q/1065374 + */ + struct extend_smp_expected { + const char *sequence; + char measurement[SHA256_SIZE]; + } expected[] = { + { + "[ cpu0#0 cpu0#1 cpu0#2 cpu1#0 cpu1#1 cpu1#2 ]", + { + 0xB1, 0xBE, 0x04, 0x25, 0xBB, 0xBC, 0x04, 0x9F, + 0x98, 0x4F, 0xFB, 0xDE, 0xAA, 0x00, 0xC9, 0xBC, + 0x41, 0x43, 0xDB, 0x16, 0xBB, 0x2A, 0x5F, 0x4B, + 0x8B, 0x36, 0xAE, 0x3F, 0xFE, 0x24, 0x23, 0xA4 + }, + }, + { + "[ cpu0#0 cpu0#1 cpu1#0 cpu0#2 cpu1#1 cpu1#2 ]", + { + 0x99, 0x00, 0x5E, 0xB7, 0xF8, 0x84, 0xA3, 0x99, + 0x7E, 0x12, 0xDE, 0xD1, 0x5B, 0xA7, 0x07, 0xF4, + 0x24, 0x3E, 0x77, 0xED, 0x60, 0xC0, 0xBD, 0x43, + 0x3B, 0x60, 0x7E, 0x38, 0xDD, 0x58, 0xC7, 0x46 + }, + }, + { + "[ cpu0#0 cpu0#1 cpu1#0 cpu1#1 cpu0#2 cpu1#2 ]", + { + 0x0B, 0x5E, 0x31, 0x69, 0xAC, 0xAF, 0xA0, 0x8B, + 0x4F, 0x90, 0xD1, 0x86, 0xCC, 0x8E, 0x11, 0x42, + 0x0B, 0x74, 0x49, 0x6C, 0xA1, 0x27, 0x1B, 0x7C, + 0x52, 0x77, 0x7F, 0x2F, 0x53, 0x2F, 0x9A, 0xC1 + }, + }, + { + "[ cpu0#0 cpu0#1 cpu1#0 cpu1#1 cpu1#2 cpu0#2 ]", + { + 0x99, 0xDE, 0xF8, 0x02, 0x27, 0xE9, 0x6F, 0x6F, + 0xA6, 0x55, 0xFC, 0x56, 0xCC, 0x7A, 0xFC, 0xEF, + 0x2F, 0x0C, 0x45, 0x3E, 0x01, 0xE0, 0x4B, 0xA1, + 0x60, 0x96, 0xEE, 0xB1, 0x4A, 0x25, 0x86, 0x89}, + }, + { + "[ cpu0#0 cpu1#0 cpu0#1 cpu0#2 cpu1#1 cpu1#2 ]", + { 0x88, 0x40, 0x05, 0xF5, 0xA6, 0x95, 0xC1, 0xC7, + 0xD3, 0x69, 0x16, 0x82, 0x0D, 0x79, 0xC1, 0x5B, + 0x4A, 0x48, 0xCA, 0x7F, 0xA5, 0xF3, 0x77, 0x37, + 0xBE, 0x0D, 0xAC, 0x2E, 0x42, 0x3E, 0x03, 0x37 + }, + }, + { + "[ cpu0#0 cpu1#0 cpu0#1 cpu1#1 cpu0#2 cpu1#2 ]", + { + 0x68, 0x32, 0xC6, 0xAF, 0x8C, 0x86, 0x77, 0x09, + 0x4A, 0xB9, 0xA1, 0x9E, 0xBB, 0x2B, 0x42, 0x35, + 0xF8, 0xDE, 0x9A, 0x98, 0x37, 0x7B, 0x3E, 0x82, + 0x59, 0x0B, 0xC4, 0xAD, 0x1D, 0x01, 0x28, 0xCA + }, + }, + { + "[ cpu0#0 cpu1#0 cpu0#1 cpu1#1 cpu1#2 cpu0#2 ]", + { + 0xF5, 0x96, 0x77, 0x68, 0xD9, 0x6A, 0xA2, 0xFC, + 0x08, 0x8C, 0xF5, 0xA9, 0x6B, 0xE7, 0x1E, 0x20, + 0x35, 0xC1, 0x92, 0xCE, 0xBC, 0x3A, 0x75, 0xEA, + 0xB4, 0xEB, 0x17, 0xE5, 0x77, 0x50, 0x85, 0x40 + }, + + }, + { + "[ cpu0#0 cpu1#0 cpu1#1 cpu0#1 cpu0#2 cpu1#2 ]", + { + 0x4E, 0xA2, 0xD2, 0x79, 0x55, 0x75, 0xCB, 0x86, + 0x87, 0x34, 0x35, 0xE7, 0x75, 0xDF, 0xD5, 0x59, + 0x58, 0xDE, 0x74, 0x35, 0x68, 0x2B, 0xDC, 0xC8, + 0x85, 0x72, 0x97, 0xBE, 0x58, 0xB1, 0x1E, 0xA7 + }, + + }, + { + "[ cpu0#0 cpu1#0 cpu1#1 cpu0#1 cpu1#2 cpu0#2 ]", + { + 0xD1, 0xC2, 0xC8, 0x08, 0x00, 0x64, 0xB8, 0x1F, + 0xA0, 0xA5, 0x32, 0x20, 0xAA, 0x08, 0xC0, 0x48, + 0xDB, 0xB1, 0xED, 0xE7, 0xAF, 0x18, 0x2F, 0x7F, + 0x3C, 0xB8, 0x58, 0x83, 0xEC, 0xF9, 0x38, 0xFD + }, + + }, + { + "[ cpu0#0 cpu1#0 cpu1#1 cpu1#2 cpu0#1 cpu0#2 ]", + { + 0xD1, 0xB8, 0x31, 0x98, 0x8E, 0xF2, 0xE7, 0xF5, + 0xBB, 0xD1, 0xE1, 0xC7, 0x3E, 0xB7, 0xA9, 0x18, + 0x3B, 0xCC, 0x58, 0x98, 0xED, 0x22, 0x1E, 0xE2, + 0x04, 0x76, 0xA1, 0xB9, 0x92, 0x54, 0xB5, 0x5B + }, + + }, + { + "[ cpu1#0 cpu0#0 cpu0#1 cpu0#2 cpu1#1 cpu1#2 ]", + { + 0xAB, 0x50, 0x2A, 0x68, 0x28, 0x35, 0x16, 0xA9, + 0xDE, 0x26, 0x77, 0xAA, 0x99, 0x29, 0x0E, 0x9C, + 0x67, 0x41, 0x64, 0x28, 0x6E, 0xFF, 0x54, 0x33, + 0xE5, 0x29, 0xC4, 0xA5, 0x98, 0x40, 0x7E, 0xC9 + }, + + }, + { + "[ cpu1#0 cpu0#0 cpu0#1 cpu1#1 cpu0#2 cpu1#2 ]", + { + 0xA3, 0x4D, 0xB0, 0x28, 0xAB, 0x01, 0x56, 0xBB, + 0x7D, 0xE5, 0x0E, 0x86, 0x26, 0xBB, 0xBB, 0xDE, + 0x58, 0x91, 0x88, 0xBB, 0x9F, 0x6A, 0x58, 0x78, + 0x30, 0x2C, 0x22, 0x2E, 0x85, 0x7F, 0x87, 0xF6 + }, + + }, + { + "[ cpu1#0 cpu0#0 cpu0#1 cpu1#1 cpu1#2 cpu0#2 ]", + { + 0x1A, 0x2E, 0xD2, 0xC2, 0x0C, 0xBD, 0x30, 0xDA, + 0x4F, 0x37, 0x6B, 0x90, 0xE3, 0x67, 0xFE, 0x61, + 0x4F, 0x30, 0xBB, 0x29, 0xBC, 0xAA, 0x6E, 0xC5, + 0x60, 0x6E, 0x13, 0x6B, 0x33, 0x3D, 0xC0, 0x11 + }, + + }, + { + "[ cpu1#0 cpu0#0 cpu1#1 cpu0#1 cpu0#2 cpu1#2 ]", + { + 0x8F, 0xEA, 0xD1, 0x80, 0xE0, 0xBE, 0x27, 0xF7, + 0x8D, 0x19, 0xBF, 0x65, 0xBE, 0x92, 0x83, 0x7C, + 0x61, 0x8F, 0xC5, 0x8D, 0x0F, 0xAD, 0x89, 0x1E, + 0xAE, 0x0A, 0x75, 0xAC, 0x3E, 0x5F, 0xD5, 0x31 + }, + + }, + { + "[ cpu1#0 cpu0#0 cpu1#1 cpu0#1 cpu1#2 cpu0#2 ]", + { + 0x0F, 0x7B, 0xEE, 0xA5, 0x9A, 0xCD, 0xED, 0x8D, + 0x5A, 0x52, 0xFF, 0xD6, 0x30, 0xF4, 0xD9, 0xE9, + 0xF4, 0xC1, 0x1A, 0x0C, 0x86, 0x2B, 0x96, 0x2C, + 0x0E, 0x2D, 0x1A, 0x2A, 0xFE, 0xE6, 0x7C, 0xAD + }, + + }, + { + "[ cpu1#0 cpu0#0 cpu1#1 cpu1#2 cpu0#1 cpu0#2 ]", + { + 0x4A, 0xBA, 0xFF, 0x0B, 0x0B, 0x06, 0xD1, 0xCE, + 0x95, 0x91, 0x70, 0x68, 0x20, 0xD6, 0xF2, 0x23, + 0xC5, 0x6A, 0x63, 0x2B, 0xCA, 0xDF, 0x37, 0xB5, + 0x0B, 0xDC, 0x64, 0x6A, 0xA3, 0xC9, 0x8F, 0x1E + }, + + }, + { + "[ cpu1#0 cpu1#1 cpu0#0 cpu0#1 cpu0#2 cpu1#2 ]", + { + 0x3D, 0xB1, 0xE1, 0xBD, 0x85, 0x2C, 0xA0, 0x04, + 0xE6, 0x43, 0xE8, 0x82, 0xC3, 0x77, 0xF3, 0xCE, + 0x4D, 0x62, 0x2C, 0xF4, 0x65, 0xF6, 0x29, 0x5F, + 0x17, 0xDA, 0xD5, 0x79, 0x55, 0xE2, 0x3D, 0x0C + }, + + }, + { + "[ cpu1#0 cpu1#1 cpu0#0 cpu0#1 cpu1#2 cpu0#2 ]", + { + 0x5B, 0xFE, 0x29, 0xA4, 0xDA, 0x9F, 0xE7, 0x13, + 0x5F, 0xA2, 0xCE, 0x53, 0x40, 0xC0, 0x38, 0xBC, + 0x10, 0x7A, 0xF0, 0x29, 0x3C, 0xD6, 0xAF, 0x8A, + 0x03, 0x40, 0xED, 0xE1, 0xFD, 0x46, 0xB7, 0x06 + }, + + }, + { + "[ cpu1#0 cpu1#1 cpu0#0 cpu1#2 cpu0#1 cpu0#2 ]", + { + 0x66, 0x20, 0xA7, 0xBE, 0xED, 0x90, 0x0A, 0x14, + 0x95, 0x7A, 0x93, 0x47, 0x1E, 0xA8, 0xDD, 0x6E, + 0x25, 0xCB, 0x73, 0x18, 0x77, 0x77, 0x91, 0xE9, + 0xCA, 0x17, 0x26, 0x16, 0xAA, 0xC9, 0x34, 0x7A + }, + + }, + { + "[ cpu1#0 cpu1#1 cpu1#2 cpu0#0 cpu0#1 cpu0#2 ]", + { + 0x4D, 0xF6, 0xC7, 0x74, 0x37, 0x66, 0x4C, 0x6A, + 0x40, 0x32, 0x94, 0x01, 0x17, 0xA2, 0xE6, 0x3D, + 0xA8, 0x00, 0x3E, 0xB7, 0x89, 0x24, 0xF4, 0x04, + 0x14, 0xA8, 0xA1, 0xD1, 0xCD, 0x5B, 0xC3, 0x60 + }, + + }, + }; + + struct cpu_extend_run cpus[2] = { + /* CPU0 */ + { .idx = &slot, .m = &m[0], .size = SHA256_SIZE }, + /* CPU1 */ + { .idx = &slot, .m = &m[1], .size = SHA256_SIZE }, + }; + + for (slot = 1; slot <= REM_COUNT; slot++) { + for (m_idx = 0; m_idx < 3; m_idx++) { + memcpy(m[0].words, &measure_bytes[m_idx * 8], SHA256_SIZE); + memcpy(m[1].words, &measure_bytes[24 + m_idx * 8], SHA256_SIZE); + on_cpus(cpu_run_extend_measurement, (void *)&cpus[0]); + if (cpus[0].rc || cpus[1].rc) + return; + } + } + + /* Get the token and parse the claims */ + memset(page_buf_data, 0, sizeof(page_buf_data)); + memset(&ch, 0xAB, sizeof(ch)); + if (!get_attest_token_claims(page_buf_data, &ch, &claims, &token_size)) + return; + + /* + * Hard-coded test data expects sha-256 algorithm, skip the measurement + * value comparison if realm hash algo is different. + */ + if (!claims_uses_sha256_algo(&claims)) { + report_skip("Hash algo is different than sha-256," + " skip measurement value comparison"); + return; + } + + for (slot = 0; slot < REM_COUNT; slot++) { + struct claim_t *claim = &claims.realm_measurement_claims[slot]; + const char *data = claim->buffer_data.ptr; + const size_t len = claim->buffer_data.len; + + if (len != SHA256_SIZE) { + report(false, "Realm measurement size mismatch " + "%zu vs %d (expected)", len, SHA256_SIZE); + continue; + } + + for (m_idx = 0; m_idx < ARRAY_SIZE(expected); m_idx++) { + struct extend_smp_expected *em = &expected[m_idx]; + + if (memcmp(data, em->measurement, SHA256_SIZE) == 0) { + report(true, "Hash found for slot %d: %s", + slot, em->sequence); + break; + } + } + + if (m_idx == ARRAY_SIZE(expected)) + report(false, "Measurement doesn't match any expected " + "sequence for slot %d", slot); + } +} + +static void run_rsi_extend_smp_tests(void) +{ + report_prefix_push("extend_smp"); + test_rsi_extend_smp(); + report_prefix_pop(); +} + +static void test_rsi_extend_and_attest(void) +{ + struct challenge ch; + struct measurement m; + struct attestation_claims claims; + size_t token_size; + int i, j; + + char measure_bytes[] = { + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, /*slot 1*/ + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, /*slot 2*/ + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, /*slot 3*/ + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, /*slot 4*/ + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /*slot 5*/ + 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, /*slot 6*/ + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27 + }; + + /* The following expectations assume extending with SHA256 */ + char expected_measurements[][SHA256_SIZE] = { + { + 0x88, 0x78, 0xb1, 0x5a, 0x7d, 0x6a, 0x3a, 0x4f, + 0x46, 0x4e, 0x8f, 0x9f, 0x42, 0x59, 0x1d, 0xbc, + 0x0c, 0xf4, 0xbe, 0xde, 0xa0, 0xec, 0x30, 0x90, + 0x03, 0xd2, 0xb2, 0xee, 0x53, 0x65, 0x5e, 0xf8 + }, + { + 0x58, 0x32, 0x3b, 0xdf, 0x7a, 0x91, 0xf6, 0x8e, + 0x80, 0xc7, 0xc8, 0x7f, 0xda, 0x1e, 0x22, 0x6c, + 0x8b, 0xe7, 0xee, 0xa9, 0xef, 0x64, 0xa5, 0x21, + 0xdb, 0x2c, 0x09, 0xa7, 0xd7, 0x01, 0x92, 0x05 + }, + { + 0x66, 0xe3, 0x3b, 0x99, 0x49, 0x4d, 0xf4, 0xdd, + 0xbc, 0x7a, 0x61, 0x7a, 0xa1, 0x56, 0x7b, 0xf8, + 0x96, 0x3f, 0x0a, 0xf3, 0x1e, 0xab, 0xdd, 0x16, + 0x37, 0xb0, 0xfb, 0xe0, 0x71, 0x82, 0x66, 0xce + }, + { + 0x97, 0x5e, 0x9f, 0x64, 0x79, 0x90, 0xa1, 0x51, + 0xd2, 0x5b, 0x73, 0x75, 0x50, 0x94, 0xeb, 0x54, + 0x90, 0xbb, 0x1e, 0xf8, 0x3b, 0x2c, 0xb8, 0x3b, + 0x6f, 0x24, 0xf3, 0x86, 0x07, 0xe0, 0x58, 0x13 + }, + { + 0x68, 0x99, 0x86, 0x64, 0x9b, 0xeb, 0xa2, 0xe4, + 0x4d, 0x07, 0xbb, 0xb3, 0xa1, 0xd9, 0x2d, 0x07, + 0x76, 0x7f, 0x86, 0x19, 0xb8, 0x5f, 0x14, 0x48, + 0x1f, 0x38, 0x4b, 0x87, 0x51, 0xdc, 0x10, 0x31 + }, + { + 0xee, 0x8f, 0xb3, 0xe9, 0xc8, 0xa5, 0xbe, 0x4f, + 0x12, 0x90, 0x4a, 0x52, 0xb9, 0xc8, 0x62, 0xd1, + 0x8a, 0x44, 0x31, 0xf7, 0x56, 0x7d, 0x96, 0xda, + 0x97, 0x7a, 0x9e, 0x96, 0xae, 0x6a, 0x78, 0x43 + }, + }; + int times_to_extend[] = {1, 2, 3, 4, 5, 6}; + + memset(page_buf_data, 0, sizeof(page_buf_data)); + memset(&ch, 0xAB, sizeof(ch)); + if (!__get_attest_token_claims(page_buf_data, &ch, + &claims, &token_size, true)) + return; + + for (i = 0; i < REM_COUNT; i++) { + struct claim_t c = claims.realm_measurement_claims[i]; + for (j = 0; j < c.buffer_data.len; j++) { + if (((char *)c.buffer_data.ptr)[j]) + break; + } + } + + report((i == REM_COUNT), "Initial measurements must be 0"); + + /* Extend the possible measurements (i.e., 1 to REM_COUNT) */ + for (i = 1; i <= REM_COUNT; i++) { + memcpy(&m.words[0], &measure_bytes[(i - 1) * 8], SHA256_SIZE); + for (j = 0; j < times_to_extend[i - 1]; j++) { + struct smccc_result r; + + measurement_extend(i, &m, SHA256_SIZE, &r); + if (r.r0) { + report(false, "Extend measurment slot %d, iteration %d " + "failed with %ld", i, j, r.r0); + return; + } + } + } + report(true, "Extend measurement for all slots completed"); + + /* Get the attestation token again */ + if (!__get_attest_token_claims(page_buf_data, &ch, + &claims, &token_size, true)) + return; + + /* + * Hard-coded test data expects sha-256 algorithm, skip the measurement + * value comparison if realm hash algo is different. + */ + if (!claims_uses_sha256_algo(&claims)) + return; + + /* Verify the extended measurements */ + for (i = 0; i < REM_COUNT; i++) { + const char *exp = expected_measurements[i]; + const char *actual = claims.realm_measurement_claims[i].buffer_data.ptr; + const size_t len = claims.realm_measurement_claims[i].buffer_data.len; + + if (len != SHA256_SIZE) { + report(false, "Realm measurement: slot: %d, unexpected size " + "actual %ld vs %d expected", i, len, + SHA256_SIZE); + return; + } + if (memcmp(exp, actual, len)) { + report(false, "Measurement doesn't match for slot %d", i); + printf("Expected:\n"); + for (j = 0; j < len; j++) + printf("0x%2x ", exp[j]); + printf("\nActual:\n"); + for (j = 0; j < len; j++) + printf("0x%2x ", actual[j]); + printf("\n"); + } else { + report(true, "Extended measurement match expected for " + "slot %d", i); + + } + } +} + +static void run_rsi_extend_and_attest_tests(void) +{ + report_prefix_push("extend_and_attest"); + test_rsi_extend_and_attest(); + report_prefix_pop(); +} + +#define MEASUREMENT_MAX_SIZE_LONGS 8 + +static void test_read_measurement(void) +{ + struct smccc_result result; + return_code_t rc; + unsigned long *m; + int i, j; + + /* + * We must be able to read all measurements + * 0 (Initial read-only measurement and the + * realm extendable ones, 1 to REM_COUNT. + */ + for (i = 0; i <= REM_COUNT; i++) { + rsi_read_measurement(i, &result); + rc = unpack_return_code(result.r0); + if (rc.status) { + report(false, "Read measurement failed for slot %d with " + "(%d, %d)", i, rc.status, rc.index); + return; + } + m = &result.r1; + printf("Read measurement slot:%d, Hash = ", i); + for (j = 0; j < MEASUREMENT_MAX_SIZE_LONGS; j++) + printf("%lx", __builtin_bswap64(*m++)); + printf("\n"); + report(true, "Read Measurement Slot: %d", i); + } +} + +static void test_read_measurement_bad_input(void) +{ + struct smccc_result result; + return_code_t rc; + + report_prefix_push("out-of-range index"); + rsi_read_measurement(REM_COUNT + 1, &result); + rc = unpack_return_code(result.r0); + if (rc.status != RSI_ERROR_INPUT) { + report(false, "Read measurement fails, " + "expected (%d), got (%d)", + RSI_ERROR_INPUT, rc.status); + } else { + report(true, "Read measurement fails as expected"); + } + report_prefix_pop(); /* out-of-range index */ +} + +static void run_rsi_read_measurement_tests(void) +{ + report_prefix_push("measurement"); + test_read_measurement(); + test_read_measurement_bad_input(); + report_prefix_pop(); +} + +int main(int argc, char **argv) +{ + int i; + report_prefix_push("attestation"); + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "attest") == 0) + run_rsi_attest_tests(); + else if (strcmp(argv[i], "attest_smp") == 0) + run_rsi_attest_smp_test(); + else if (strcmp(argv[i], "extend") == 0) + run_rsi_extend_tests(); + else if (strcmp(argv[i], "extend_smp") == 0) + run_rsi_extend_smp_tests(); + else if (strcmp(argv[i], "extend_and_attest") == 0) + run_rsi_extend_and_attest_tests(); + else if (strcmp(argv[i], "measurement") == 0) + run_rsi_read_measurement_tests(); + else + report_info("Unknown subtest '%s'", argv[i]); + } + return report_summary(); +} diff --git a/arm/unittests.cfg b/arm/unittests.cfg index bc2354c7..5e9e1cbd 100644 --- a/arm/unittests.cfg +++ b/arm/unittests.cfg @@ -311,3 +311,53 @@ file = realm-sea.flat groups = nodefault realms accel = kvm arch = arm64 + +# Realm Attestation realted tests +[realm-attest] +file = realm-attest.flat +groups = nodefault realms +smp = 1 +extra_params = -m 32 -append 'attest' +accel = kvm +arch = arm64 + +[realm-attest-smp] +file = realm-attest.flat +groups = nodefault realms +smp = 2 +extra_params = -m 32 -append 'attest_smp' +accel = kvm +arch = arm64 + +[realm-extend] +file = realm-attest.flat +groups = nodefault realms +smp = 1 +extra_params = -m 32 -append 'extend' +accel = kvm +arch = arm64 + +[realm-extend-smp] +file = realm-attest.flat +groups = nodefault realms +smp = 2 +extra_params = -m 32 -append 'extend_smp' +accel = kvm +arch = arm64 + +[realm-extend-and-attest] +file = realm-attest.flat +groups = nodefault realms +smp = 1 +extra_params = -m 32 -append 'extend_and_attest' +accel = kvm +arch = arm64 + + +[realm-measurement] +file = realm-attest.flat +groups = nodefault realms +smp = 1 +extra_params = -m 32 -append 'measurement' +accel = kvm +arch = arm64 diff --git a/lib/libcflat.h b/lib/libcflat.h index c1fd31ff..893fee6f 100644 --- a/lib/libcflat.h +++ b/lib/libcflat.h @@ -163,6 +163,7 @@ extern void setup_vm(void); #define SZ_64K (1 << 16) #define SZ_1M (1 << 20) #define SZ_2M (1 << 21) +#define SZ_512M (1 << 29) #define SZ_1G (1 << 30) #define SZ_2G (1ul << 31) From patchwork Fri Jan 27 11:41:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13118649 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 79AC8C38142 for ; Fri, 27 Jan 2023 12:42:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=lnOUXh4amtJPWhZWMYejtNZ2Ne+o6iZlVGslmRM+MB4=; b=O6EyrPS3tOyQYl 6HBGJehsnStrxS5Ta8BqNIGtgwPXYk3RUHfI7UbiervjnaaVxjWpQwQthGPBBnoWLnsjkzVNk8Q6M YVpobLpJM3+3OcIJ+cP3qWFzO2c0e6QP8Yesn6Jba7+ImMuOUHApR82dIYdyH7f834r8FMPHbyPxA WdGyV5LG9HtNgVIo3dQwyKF1YopUPPJT0OG4p2MH+hXCexsHYNYSJXCCYrnq9FBKkCRxywPJJmyeK yqhjPzVwrD7626OQDwSRnwN40qgKGuwoc7VT+JEyKaMz3P75+g+U8bm4PCL8UosiN1W3HApaS/74a JtGsyv45wNEvlOR3K+yw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLO1X-00EeIC-0a; Fri, 27 Jan 2023 12:40:09 +0000 Received: from mail-vi1eur04on2054.outbound.protection.outlook.com ([40.107.8.54] helo=EUR04-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN9F-00EEjB-GM for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:44:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QAU9Jgz+nQreSzKTkls21fkkUSuTh4SKSeI2vmAyKUU=; b=75tQeKiwqMW67204SrfhDlHcJnZyDxaHRQypFqOHW8ppth8NoVbJ2MesTAxmAcNBWL6QwpO0KCwIepIgrFuUbN9PZNSMOv3z5gSIbxBFGXz0Y7n2UkZOnBg1xMCTEoBJmjcvQdLR96L80IhyYVrTpVDJL6/RZpLduUrpr6vOlUs= Received: from AS9PR06CA0237.eurprd06.prod.outlook.com (2603:10a6:20b:45e::24) by AS2PR08MB8381.eurprd08.prod.outlook.com (2603:10a6:20b:558::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.33; Fri, 27 Jan 2023 11:43:53 +0000 Received: from AM7EUR03FT049.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:45e:cafe::c5) by AS9PR06CA0237.outlook.office365.com (2603:10a6:20b:45e::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.22 via Frontend Transport; Fri, 27 Jan 2023 11:43:53 +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 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM7EUR03FT049.mail.protection.outlook.com (100.127.140.234) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23 via Frontend Transport; Fri, 27 Jan 2023 11:43:53 +0000 Received: ("Tessian outbound 6e565e48ed4a:v132"); Fri, 27 Jan 2023 11:43:53 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: bdea91f2db7b85cc X-CR-MTA-TID: 64aa7808 Received: from cfce6ef35b14.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 2FFD23B1-21B3-4251-BC26-5FDF25251ACC.1; Fri, 27 Jan 2023 11:43:46 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id cfce6ef35b14.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 27 Jan 2023 11:43:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eKP7VgpkPLaMMTn3asblc203JyxWehrF7Z8DpFutJYeUtb9U+Y8USc7R0nXxQXZ1YYuJ2hk92irkAsgG9qzTwjreZIuws0l7IMsBbbSVk1WDVY5r/ulejpdaQ1OjjHN8/TRdGzmpVkXr+oYr3MjHMOCwt3FJM67Z0gO19LHwXWwittwU6ozr7IBNBj/KTNoz+kv7rom9rmU6mAppepzCE17Sz+ZCdHRauBwbgdStv06jH++9nZgmZnsADU23QRdeAlN/Aj7EXhT1uGbLu2r3J7vn8eeoz4/E/Ybh4zxykqjxHigIQiZ8Wb1PwLCFYu/Rdi56SMFkHFa9SCwYDcmMiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QAU9Jgz+nQreSzKTkls21fkkUSuTh4SKSeI2vmAyKUU=; b=C/o3oYkYDQwpSslko86r3Vdlrd/7xwbUDdr6/QQRuocUJyoFMov8yadBnElM5VvVEUdP2u1vl8Q8Gkhag1juvD9/m5fIR4ShnUwZD6cVTnaw30sMOPnqWG/D03LZZxgoamw+1EBghffhjPe4bOP63kcB4Zw3j3IlnWETl778op2WyTzHHhC0oab4sxwMWYAhCJl9V+yQ/5zUvO+HKATDUoQ1ZnV6QQ28d1yzgPDaLs5QdMoY92HpXlySUifHxbKrHeGrcs+mmZ8XpVc8fjDIYpCqUZFCtR+PozPmYKq5HTu9ozz1AvtoPnkcQ+RXa5PVlYCdSMY7vyZ588QTkieH2g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=linux.dev smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QAU9Jgz+nQreSzKTkls21fkkUSuTh4SKSeI2vmAyKUU=; b=75tQeKiwqMW67204SrfhDlHcJnZyDxaHRQypFqOHW8ppth8NoVbJ2MesTAxmAcNBWL6QwpO0KCwIepIgrFuUbN9PZNSMOv3z5gSIbxBFGXz0Y7n2UkZOnBg1xMCTEoBJmjcvQdLR96L80IhyYVrTpVDJL6/RZpLduUrpr6vOlUs= Received: from AM6PR05CA0007.eurprd05.prod.outlook.com (2603:10a6:20b:2e::20) by DU0PR08MB9934.eurprd08.prod.outlook.com (2603:10a6:10:402::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.22; Fri, 27 Jan 2023 11:43:43 +0000 Received: from AM7EUR03FT051.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:2e:cafe::49) by AM6PR05CA0007.outlook.office365.com (2603:10a6:20b:2e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23 via Frontend Transport; Fri, 27 Jan 2023 11:43:43 +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 Received: from nebula.arm.com (40.67.248.234) by AM7EUR03FT051.mail.protection.outlook.com (100.127.140.64) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6043.22 via Frontend Transport; Fri, 27 Jan 2023 11:43:43 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) 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.16; Fri, 27 Jan 2023 11:43:43 +0000 Received: from e124191.cambridge.arm.com (10.1.197.45) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Fri, 27 Jan 2023 11:43:37 +0000 From: Joey Gouly To: Andrew Jones , , CC: , Alexandru Elisei , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Suzuki K Poulose , "Thomas Huth" , Will Deacon , Zenghui Yu , , , , Subject: [RFC kvm-unit-tests 26/27] arm: realm: Add a test for shared memory Date: Fri, 27 Jan 2023 11:41:07 +0000 Message-ID: <20230127114108.10025-27-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230127114108.10025-1-joey.gouly@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127114108.10025-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT051:EE_|DU0PR08MB9934:EE_|AM7EUR03FT049:EE_|AS2PR08MB8381:EE_ X-MS-Office365-Filtering-Correlation-Id: 38bc063b-9476-4a1d-c95a-08db005bc406 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: D45yi0Hl78fvSE8pvxxw5w6KIODVe8P3g15pwobflgGHqolMqMRHHjlBiOcvjIGo5nmtsVWqDBiTaFmUccU5rb4Z1hDyZZ/eksLuasMussDthphCqel3+rBAJmZSoum0YiuC7CQxG3COvZM2BsS3Oo6gZgz+fK0gF2EB7/rF6N8N2TjKOXx1IPnrFVVvQPMm1gn729lFvfE6O9qPGQDLCFfMPhqWBXnwFoOK+8n0QX7YVkdcbPy0JRlrNgTVschr1S+2ix9k2ip70gHKqHpwZXk4OIWrFHuZA5BM+9Pu/5cwAEP/XFdsghneoGhxmZPkNJnzhm5I5OZyYLKUtxqnuu0gtPD+zTx/M+//6TMl47RLV1oCWQxndc52IXRSbcNCh5+ECA8Ac4JT26eXU/JY3P0WffodL7QhIH/zFxoovJjslyGK/x8udxdipedGtIuzVGsTMSO/49DqVjrZEpvKj0s8JSmpZcC24uAbEKMGR+r9gr69Y3/ZLzQcmY30nYQvPP0RxVsua0NK4Sd1gIeyHpVBIM2uekVcvCHbR02uhW+FDgohFrXE1/WGD18CbiPelvCCmYugZBzl6QbQMgMOSx5Iv4b6Xl5kkY+qR4Iu6kNoKf8694RV9hhgzPFCjvWtS/aVSCKk6h3/vJByCV1PxoeT2emQVkaVbgiglXR8eixRoTxPzlxot7rivXxVc6SaQXQ4QSs783Uw1NbEo6LDsTvG5VgCfdwOov555dIw+VLZhPjT71igqhpFjWc0hr0J 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:(13230025)(4636009)(346002)(376002)(39860400002)(136003)(396003)(451199018)(40470700004)(36840700001)(46966006)(44832011)(82740400003)(83380400001)(82310400005)(36860700001)(356005)(7416002)(336012)(5660300002)(426003)(8936002)(2906002)(2616005)(47076005)(81166007)(86362001)(186003)(26005)(7696005)(40480700001)(1076003)(478600001)(70206006)(6666004)(54906003)(40460700003)(4326008)(8676002)(110136005)(316002)(70586007)(36756003)(41300700001)(2101003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB9934 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT049.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: adaa99ea-621c-4e95-7e7a-08db005bbe3f X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Wwfs0tCMSCHM1CjLwwBmqstcg4aa38zCrpfdu5ya1XOVAzyN/Ceg6kdOlZ+cnTkN9AsHjwLFX+Q6Y65Jzb9mp7EYsWf5R/uGlKpSCQrZO+wJR70+oHJz7MKaSrPDIGHnVD0sOmyubW8yunJPxv3m/mtM9KGexaQLZyXwL+tVOg5tJ3DKY5af0MFwgFmJsqDj+NLpOK0RW0Eo8vcOKVQEdBLw2cdCTOxByk1B911pR+By64AOHNTkunJkeBFI2jUw1/CduW8KETZphpBqmBaZ6Dee+zg5ZT9fw/L2YPRvzAi9+nCUoCMXNH3CxHCFMcSaHzcFKi42auo3zKsGdNaxki0exRkbDR7J6iEcOrUG0/OOPDlYUIOpNkBgFznrTFur/tUWN6zIf6LllW5EkjuQFgTZkpYQ2mfTfHA8OQ7KMwvCeDD6WwvOcPd1Gnuy3FIoBKJLUcU6lN+SMpm0Fxzv/46elMdyr/hG6oImaht8vKbDRv0rnwqJDQTxx/H2GwU3Q0ZFm7kQjbQ+OnX2mVzMO2+rmSG10IaAfjz8eU7WhRmbbOZ8WdXvn50ARJr9BmYRQWtVjZJLKUyB5/twk4ZqTvhdPDfBKlChdEmyl3X3kKde8893Yn2ZT+8x6KwNxcyZzG81jpGZwMoTmGeuxxup/U9y2A6v9bMjmXrOHGztLik8E15PMfVdfMcn8sqiYRCqFjviaAm2Wx/gbNtUS3N5YzkA41Mmo7R8qwaUg7RunRA= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230025)(4636009)(346002)(376002)(136003)(396003)(39860400002)(451199018)(36840700001)(40470700004)(46966006)(40460700003)(36756003)(81166007)(36860700001)(5660300002)(2906002)(82740400003)(1076003)(6666004)(26005)(83380400001)(110136005)(316002)(54906003)(8936002)(7696005)(107886003)(40480700001)(41300700001)(86362001)(2616005)(8676002)(426003)(44832011)(478600001)(4326008)(47076005)(186003)(70586007)(82310400005)(70206006)(336012)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2023 11:43:53.3391 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 38bc063b-9476-4a1d-c95a-08db005bc406 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: AM7EUR03FT049.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB8381 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034401_766202_2EF5A19F X-CRM114-Status: GOOD ( 18.24 ) 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 From: Suzuki K Poulose Do some basic tests that trigger marking a memory region as RIPAS_EMPTY and accessing the shared memory. Also, convert it back to RAM and make sure the contents are scrubbed. Signed-off-by: Suzuki K Poulose Signed-off-by: Joey Gouly --- arm/Makefile.arm64 | 1 + arm/realm-ns-memory.c | 86 +++++++++++++++++++++++++++++++++++++++++++ arm/unittests.cfg | 8 ++++ 3 files changed, 95 insertions(+) create mode 100644 arm/realm-ns-memory.c diff --git a/arm/Makefile.arm64 b/arm/Makefile.arm64 index 0a0c4f2c..9b41e841 100644 --- a/arm/Makefile.arm64 +++ b/arm/Makefile.arm64 @@ -44,6 +44,7 @@ tests += $(TEST_DIR)/realm-rsi.flat tests += $(TEST_DIR)/realm-attest.flat tests += $(TEST_DIR)/realm-fpu.flat tests += $(TEST_DIR)/realm-sea.flat +tests += $(TEST_DIR)/realm-ns-memory.flat include $(SRCDIR)/$(TEST_DIR)/Makefile.common diff --git a/arm/realm-ns-memory.c b/arm/realm-ns-memory.c new file mode 100644 index 00000000..8360c371 --- /dev/null +++ b/arm/realm-ns-memory.c @@ -0,0 +1,86 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2022 Arm Limited. + * All rights reserved. + */ + +#include +#include +#include + +#define GRANULE_SIZE 0x1000 +#define BUF_SIZE (PAGE_SIZE * 2) +#define BUF_PAGES (BUF_SIZE / PAGE_SIZE) +#define BUF_GRANULES (BUF_SIZE / GRANULE_SIZE) + +static char __attribute__((aligned(PAGE_SIZE))) buffer[BUF_SIZE]; + +static void static_shared_buffer_test(void) +{ + int i; + + set_memory_decrypted((unsigned long)buffer, sizeof(buffer)); + for (i = 0; i < sizeof(buffer); i += GRANULE_SIZE) + buffer[i] = (char)i; + + /* + * Verify the content of the NS buffer + */ + for (i = 0; i < sizeof(buffer); i += GRANULE_SIZE) { + if (buffer[i] != (char)i) { + report(false, "Failed to set Non Secure memory"); + return; + } + } + + /* Make the buffer back to protected... */ + set_memory_encrypted((unsigned long)buffer, sizeof(buffer)); + /* .. and check if the contents were destroyed */ + for (i = 0; i < sizeof(buffer); i += GRANULE_SIZE) { + if (buffer[i] != 0) { + report(false, "Failed to scrub protected memory"); + return; + } + } + + report(true, "Conversion of protected memory to shared and back"); +} + +static void dynamic_shared_buffer_test(void) +{ + char *ns_buffer; + int i; + int order = get_order(BUF_PAGES); + + ns_buffer = alloc_pages_shared(order); + assert(ns_buffer); + for (i = 0; i < sizeof(buffer); i += GRANULE_SIZE) + ns_buffer[i] = (char)i; + + /* + * Verify the content of the NS buffer + */ + for (i = 0; i < sizeof(buffer); i += GRANULE_SIZE) { + if (ns_buffer[i] != (char)i) { + report(false, "Failed to set Non Secure memory"); + return; + } + } + free_pages_shared(ns_buffer); + report(true, "Dynamic allocation and free of shared memory\n"); +} + +static void ns_test(void) +{ + static_shared_buffer_test(); + dynamic_shared_buffer_test(); +} + +int main(int argc, char **argv) +{ + report_prefix_pushf("ns-memory"); + ns_test(); + report_prefix_pop(); + + return report_summary(); +} diff --git a/arm/unittests.cfg b/arm/unittests.cfg index 5e9e1cbd..8173ccfe 100644 --- a/arm/unittests.cfg +++ b/arm/unittests.cfg @@ -361,3 +361,11 @@ smp = 1 extra_params = -m 32 -append 'measurement' accel = kvm arch = arm64 + +[realm-ns-memory] +file=realm-ns-memory.flat +groups = nodefault realms +smp = 1 +extra_params = -m 32 +accel = kvm +arch = arm64 From patchwork Fri Jan 27 11:41:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13118651 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 C40B0C38142 for ; Fri, 27 Jan 2023 12:45:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PvslTV3I4uKbvG+LIjNeGFtxaZzP+9M5e7o50KrNsZ8=; b=3wI3v6euRsGxJN rMGEQqW482YJw2pXD7QHCu71Ur2Teymmmgg2sJUGxzwWvaz5I2IAYP85UIL1YyoyLFkHHoYvtzA4A rPPSl9knF8ysJjUOh4I5f5X4kqaZ+2E2HsmivG3A+CInSxa9yQfNa5neWrlDj/HVisXJWvvMFHpUK k3FzvkvWL/NYpZXCXtqY9kY1+AJkBIYt7cxGqgNs8lOVYE2Rpf1Llp4T4tYPCsNDpY7Fw1LpX6+cG h5xcCCdXT6ARh1Spk3Nf9HKCSnTHKIG/20QSqHONg3ce/pGTHMK3+XTGOLLFJY/XMv2o10jyPmi5P xObMsa+/I6aLoY2djIvg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLO4x-00EgPb-2W; Fri, 27 Jan 2023 12:43:44 +0000 Received: from mail-vi1eur05on20606.outbound.protection.outlook.com ([2a01:111:f400:7d00::606] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN9L-00EElo-E7 for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:44:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kO8hkE7cAfjRQTMEdbSYVkx4yeMpZCun0pWnYUIRFJg=; b=nLKdm8NMlONskRd10en+rfB3Pp9M+pjmgWdV1jrvf5lpFU16578qxxCECTBR0DmYZvRN0wrfKYo89N1JObK751g9EGxQrT+jGpUN1J1morxpK3AeqlnIjm+E0IOp0EfEPA5eU/L9DRIg/1Zo7vuW8IxzrG7+aulOMVluKEmtU34= Received: from DU2PR04CA0357.eurprd04.prod.outlook.com (2603:10a6:10:2b4::32) by DB9PR08MB7866.eurprd08.prod.outlook.com (2603:10a6:10:39d::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23; Fri, 27 Jan 2023 11:44:01 +0000 Received: from DBAEUR03FT045.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:2b4::4) by DU2PR04CA0357.outlook.office365.com (2603:10a6:10:2b4::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.22 via Frontend Transport; Fri, 27 Jan 2023 11:44:01 +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 Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT045.mail.protection.outlook.com (100.127.142.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.21 via Frontend Transport; Fri, 27 Jan 2023 11:44:01 +0000 Received: ("Tessian outbound 43b0faad5a68:v132"); Fri, 27 Jan 2023 11:44:00 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 403469eb871d398a X-CR-MTA-TID: 64aa7808 Received: from 218f26c7afe3.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id B97B7030-A044-480A-8423-9229F3B28E64.1; Fri, 27 Jan 2023 11:43:54 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 218f26c7afe3.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 27 Jan 2023 11:43:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L4SFUav4NYB9p52IOn/oOn7CKvWhIaSlYlgvY8f2IwoMTaaP7dCFcTG8ktBcZbAmanqDc7zLlutfnO+uHc8edTE2OzHrlxkCm/3Ahokjks8ZLpb+Ge2unWyqjwGVRWjOeBhrbvr5884rTKuwPIfJ85pN+g7h9sgaWSuCQQSVGHna5Er0Fd0lfq8DcOlx8q9GWhetO4p7Klo3kny1r5ACi+ffYu0sGssYhwu3e667q5LhZLtzUoOL8Ze8sSpY0E4clIluZMhzO/QqnIMOEQKxuK8zJ+18SM1qKgvgSMnfVCTv2d92MfW2gGeAvD2bltT/a/5r2XtmLxj8WcfspbikkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kO8hkE7cAfjRQTMEdbSYVkx4yeMpZCun0pWnYUIRFJg=; b=ime8B6GnJrjUTrsj8PBUy1ojJyVRjw3clnLiNKYn+IM2yb7aiRh6uRWLFgv8UTvLwLZSOJRBoO+RPSNBVso4OsSckxxu1fI2k+gT4C2F03ha7d+xtE25OCRmYBo5q7QIYXzlWw/ThBer2s57zh2RulvXpxXIWt9q703IhsrIt+cyuCF/+T86pRqK9i4a+w2jkrLmWvOimmGBx1mkEEL9pKgauvv+YJW3FvKLNjCIafo6muSNUlqsja215W4SnNJB1pVgGAd/HSqkL6bajurregPlnCI9FAPHQ8tULEeoTst0y2N0FlZnIZ67ZDBYDKS2TzY8QG5UGSe9hZrF/no5DQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=linux.dev smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kO8hkE7cAfjRQTMEdbSYVkx4yeMpZCun0pWnYUIRFJg=; b=nLKdm8NMlONskRd10en+rfB3Pp9M+pjmgWdV1jrvf5lpFU16578qxxCECTBR0DmYZvRN0wrfKYo89N1JObK751g9EGxQrT+jGpUN1J1morxpK3AeqlnIjm+E0IOp0EfEPA5eU/L9DRIg/1Zo7vuW8IxzrG7+aulOMVluKEmtU34= Received: from AS8PR04CA0010.eurprd04.prod.outlook.com (2603:10a6:20b:310::15) by PAXPR08MB6640.eurprd08.prod.outlook.com (2603:10a6:102:dd::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23; Fri, 27 Jan 2023 11:43:50 +0000 Received: from AM7EUR03FT036.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:310:cafe::1d) by AS8PR04CA0010.outlook.office365.com (2603:10a6:20b:310::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.23 via Frontend Transport; Fri, 27 Jan 2023 11:43:50 +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 Received: from nebula.arm.com (40.67.248.234) by AM7EUR03FT036.mail.protection.outlook.com (100.127.140.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6043.21 via Frontend Transport; Fri, 27 Jan 2023 11:43:50 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) 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.16; Fri, 27 Jan 2023 11:43:48 +0000 Received: from e124191.cambridge.arm.com (10.1.197.45) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Fri, 27 Jan 2023 11:43:43 +0000 From: Joey Gouly To: Andrew Jones , , CC: , Alexandru Elisei , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Suzuki K Poulose , "Thomas Huth" , Will Deacon , Zenghui Yu , , , , Subject: [RFC kvm-unit-tests 27/27] NOT-FOR-MERGING: add run-realm-tests Date: Fri, 27 Jan 2023 11:41:08 +0000 Message-ID: <20230127114108.10025-28-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230127114108.10025-1-joey.gouly@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127114108.10025-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT036:EE_|PAXPR08MB6640:EE_|DBAEUR03FT045:EE_|DB9PR08MB7866:EE_ X-MS-Office365-Filtering-Correlation-Id: 53ce76f9-75ff-4695-f5c0-08db005bc894 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: BRJQ17pHYeh6le9LoVuzDMU9zzZO1bzgkGCoP+3Qfew9Oen/RG8qxWTBBmxPP6hZ8xk4IR7mFeJypZ50CE+ffhsj1zUlUsqgLf6G3hZ4Sc8MOnOIMF+LsNsGMIGpe0sKyoDxZUUwLo6k92WvoxmbbGX+Iz3r/1BIfky4t9DMQzNsuP4wlxsvxgDCvmGhpIoHMoC/LHq1yeCyA4QojIgPJxJdt9noHEqTwktzmxfkv2BFVOYxfh/PBpGY0/nL0aKgoksywhWwJiNNiMdDn8wlFAdQ+2FskurOWpCRUKq1y3C+9ujzMu1MPwMgdTEfdc9JdN0JdUO1Va4w39oF7pvunZyTqTvb8m2jib9vw+MONIzuGeN2RbCV99eXICJjtDRh0KqJLieIwSU/TfYCCsmfSfzAkDH6wWpQJURkTESqNlOcKs4JLbiILEkOqP4d4JysReyMAPcqi9r/r+Vcc20B4BaLRbIaq6FFY0EGwVTsZJLaCv2LKWmRR75V4YoWOr9nhEMLOUl2KjX+yj1S+QUCs0AIxVAwjVsOHjO95+m6FdNjX6VgtSauy+fADOJmztNMRB3m15HoIQIkWiVyjXnCDXYdNH3cQTVovG0U+S7xThYEOVmp5nMnE7jneKbhc+WLFDIomrl9uA/aUTKoiG2cqc1/5wCeB5ndV0vSaALNI1csM2iWTIkea/qBqgW8aMWc4LiGFqXPi8Ig11/xzNO4D4LTZjMjEG9zZck4UqtqQIGIb5FgEAlf0eIm4/qQQ8OS 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:(13230025)(4636009)(396003)(39860400002)(136003)(376002)(346002)(451199018)(36840700001)(46966006)(40470700004)(36756003)(82310400005)(81166007)(316002)(2616005)(478600001)(186003)(26005)(1076003)(54906003)(6666004)(40460700003)(356005)(70206006)(4326008)(70586007)(336012)(7696005)(86362001)(110136005)(82740400003)(8676002)(40480700001)(426003)(44832011)(7416002)(2906002)(36860700001)(47076005)(5660300002)(41300700001)(8936002)(2101003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6640 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT045.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 689b1c3e-1a76-4b7e-4fef-08db005bc263 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uAPnTrt0XMw7IwO0NTCC/Mawtxc4mxHlRVHh7s/9jFv+MKZDJs96q3uARQfEmWyRjf4NlziGpCFJnNOx/Slkim3Lm/yE2pVh0M+yv3fEI2I/AcNH6ZKDpZPqrpC1ol/pRsqKDur0mCgJnYkclXp7kh/DTQqPniPOm8dd9F/eukSwCUMbweeOM9OzyWb+IZe3zZyjKBrQJ8Raz2WAJQWN+CiXZr1TElOGKcvsoMDJtr86tAZxfSdexmJppByJt2aLwL0vT5X2zaMRtVzDjtCFMahh+g4YgXMf8Z5lSI0Uoqbwj3vE8qrzq+jVpdveA6BFBO6nwAkyEN95SJToiy/ftTi6UdEd99+2L851m4g69TFQ1udBsad66U4ij5LiZ28D+sV5rXaSEENXxBEHdO56WOvNMFDpdZd4z6URq+RpUh5YIGVXV7OIYuXkUclDPvFw6ra2/q4JHmEyZSCicmBg6Uk1/Y+liN0bdlSyvRe8pOR75yF7aujhV4P7bg66rkHzn3ssVc4aMVK1f+y18205w23RJOXyvjQqGIiBRe65z8ME9ift3uFpHtJEoIJiJcXS3PKfYCGvmEE6eaWWn0fPII6BgTKXMuTsMSnhJv47MpFE+eDAFWxXCwhqA3HLAaYTp29AXKNEeavzg6jr0hzZkzwScgfU2yb5G2P+GPiJqt3zK4cmaslT3p0kAsytQ6pNA5yZP+xsH7GHW89DboYzzqlbnsqhAlGs0huz+cBWFkQ= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230025)(4636009)(39860400002)(396003)(376002)(346002)(136003)(451199018)(46966006)(40470700004)(36840700001)(8936002)(41300700001)(5660300002)(36860700001)(426003)(336012)(2616005)(47076005)(40460700003)(40480700001)(82740400003)(36756003)(316002)(82310400005)(110136005)(7696005)(70586007)(70206006)(54906003)(86362001)(26005)(4326008)(8676002)(186003)(478600001)(1076003)(81166007)(107886003)(6666004)(2906002)(44832011)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2023 11:44:01.0130 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 53ce76f9-75ff-4695-f5c0-08db005bc894 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: DBAEUR03FT045.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB7866 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034407_528970_E1D17BAC X-CRM114-Status: GOOD ( 11.77 ) 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 From: Alexandru Elisei Until we add support for KVMTOOL to run the tests using the scripts, provide a temporary script to run all the Realm tests. Signed-off-by: Alexandru Elisei Signed-off-by: Joey Gouly --- arm/run-realm-tests | 56 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100755 arm/run-realm-tests diff --git a/arm/run-realm-tests b/arm/run-realm-tests new file mode 100755 index 00000000..39f431d5 --- /dev/null +++ b/arm/run-realm-tests @@ -0,0 +1,56 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-only +# Copyright (C) 2023, Arm Ltd +# All rights reserved +# + +TASKSET=${TASKSET:-taskset} +LKVM=${LKVM:-lkvm} +ARGS="--realm --irqchip=gicv3 --console=serial --network mode=none --nodefaults" + +TESTDIR="." +while getopts "d:" option; do + case "${option}" in + d) TESTDIR=${OPTARG};; + ?) + exit 1 + ;; + esac +done +if [[ ! -d ${TESTDIR} ]]; then + echo "Invalid directory: ${TESTDIR}" + exit 1 +fi + +function run_tests { + DIR="$1" + + $LKVM run $ARGS -c 2 -m 16 -k $DIR/selftest.flat -p "setup smp=2 mem=16" + $LKVM run $ARGS -c 1 -m 16 -k $DIR/selftest.flat -p "vectors-kernel" + $LKVM run $ARGS -c 1 -m 16 -k $DIR/selftest.flat -p "vectors-user" + $LKVM run $ARGS -c 4 -m 32 -k $DIR/selftest.flat -p "smp" + + $LKVM run $ARGS -c 1 -m 32 -k $DIR/realm-ns-memory.flat + + $LKVM run $ARGS -c 4 -m 32 -k $DIR/psci.flat + + $LKVM run $ARGS -c 4 -m 32 -k $DIR/gic.flat -p "ipi" + $LKVM run $ARGS -c 4 -m 32 -k $DIR/gic.flat -p "active" + + $LKVM run $ARGS -c 1 -m 16 -k $DIR/timer.flat + + $LKVM run $ARGS -c 1 -m 16 -k $DIR/realm-rsi.flat -p "version" + $LKVM run $ARGS -c 1 -m 16 -k $DIR/realm-rsi.flat -p "host_call hvc" + $LKVM run $ARGS -c 1 -m 16 -k $DIR/realm-sea.flat + + $LKVM run $ARGS -c 1 -m 24 -k $DIR/realm-attest.flat -p "attest" + $LKVM run $ARGS -c 2 -m 24 -k $DIR/realm-attest.flat -p "attest_smp" + $LKVM run $ARGS -c 1 -m 24 -k $DIR/realm-attest.flat -p "extend" + $LKVM run $ARGS -c 2 -m 24 -k $DIR/realm-attest.flat -p "extend_smp" + $LKVM run $ARGS -c 1 -m 24 -k $DIR/realm-attest.flat -p "extend_and_attest" + $LKVM run $ARGS -c 1 -m 24 -k $DIR/realm-attest.flat -p "measurement" + + $TASKSET -c 0 $LKVM run $ARGS -c 4 -m 32 -k $DIR/realm-fpu.flat +} + +run_tests "${TESTDIR}"