From patchwork Fri Aug 13 16:59:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Lendacky X-Patchwork-Id: 12435957 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F9ABC432BE for ; Fri, 13 Aug 2021 17:00:25 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F2F94610FD for ; Fri, 13 Aug 2021 17:00:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org F2F94610FD Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C6E576E893; Fri, 13 Aug 2021 17:00:23 +0000 (UTC) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2069.outbound.protection.outlook.com [40.107.93.69]) by gabe.freedesktop.org (Postfix) with ESMTPS id 69C096E893; Fri, 13 Aug 2021 17:00:23 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oK/2Ut8+AGCxUJx0W5zycF1x+1t2XqAU92mfds1VP60UjNDCnHUNw8cedHlTpjai+brFHkbEwAFiDbnfrPmWQHrewRLtO0HhI+6nl5fyQnobsge5ggCM6laOfBMk0s5uI5Wxh7pUu9VJob15xl+bH4s9BO+5rTMHCYsy3zZsr/w1Ni8G95rHPbMQROFDT6hIODSeb0K2U9U/5lfV12gxzs/WVIlJrLAFtS19OIT+sGqYnkYMsT8kibIJBeFJhLLR4FdrRdkr9UApazqpmp6mOC8oL0EZSRXvBMSoezpMD5W8z5im0gs6jISYwsV+FICiinCpDxym0sfV1BVb2b4KgQ== 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-SenderADCheck; bh=7rBYhxwUFw8fcyx0fuQ206NyJJMRUZngGck8eTaViKU=; b=ixPBh0cVUClx3XazcvSoLSGIhzRwzxGV48OibUA7sLo06G7Ai5zul/+fkl/TKOBM6RGbChtxv9TzxM3iQMrvNX+JgSeyuw7kLr4/ZgzKO7TeQO5OiIMZjJEEGxkErwjXAxfkHrf4EMJrQmiNm1B1RlyqSGOmd1/TtV1I8OWpxh+qpWAvMYSDiHnfnZUclaA3/cGpQYXSNIyFzRMjLZhcCEQpW66mizS8CPdzCpN/pA1Hu45+vr1rXOy7HSyuGuw2vKHXkih2dYZkvcxihBraQLcJF0XoWX9X7PTTv6+FPh8XltQIbIRsltJ6o46qJ58EZjaNDo+PIqc+LHWebNyuSw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7rBYhxwUFw8fcyx0fuQ206NyJJMRUZngGck8eTaViKU=; b=GVgMojjDS175NnefMN+kjwSgsWvicHKrgnLflWnzkYu1E+ihwWIVwsZi6W1puvRbBZP6enC6s28BGlg24IjQ4moo/RnwC6K0QStCVdRfJjgBrE+hQBzY3t/SMrEO+BIdlV8gnvGyGnvggOo3zLQAF0otdFhgrvscggqXzgUstww= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=amd.com; Received: from DM4PR12MB5229.namprd12.prod.outlook.com (2603:10b6:5:398::12) by DM6PR12MB5535.namprd12.prod.outlook.com (2603:10b6:5:20a::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.14; Fri, 13 Aug 2021 17:00:21 +0000 Received: from DM4PR12MB5229.namprd12.prod.outlook.com ([fe80::d560:d21:cd59:9418]) by DM4PR12MB5229.namprd12.prod.outlook.com ([fe80::d560:d21:cd59:9418%6]) with mapi id 15.20.4415.019; Fri, 13 Aug 2021 17:00:21 +0000 From: Tom Lendacky To: linux-kernel@vger.kernel.org, x86@kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, iommu@lists.linux-foundation.org, kvm@vger.kernel.org, linux-efi@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-graphics-maintainer@vmware.com, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, kexec@lists.infradead.org, linux-fsdevel@vger.kernel.org Cc: Borislav Petkov , Brijesh Singh , Joerg Roedel , Andi Kleen , Sathyanarayanan Kuppuswamy , Tianyu Lan , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras Subject: [PATCH v2 04/12] powerpc/pseries/svm: Add a powerpc version of prot_guest_has() Date: Fri, 13 Aug 2021 11:59:23 -0500 Message-Id: <000f627ce20c6504dd8d118d85bd69e7717b752f.1628873970.git.thomas.lendacky@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-ClientProxiedBy: SA0PR11CA0100.namprd11.prod.outlook.com (2603:10b6:806:d1::15) To DM4PR12MB5229.namprd12.prod.outlook.com (2603:10b6:5:398::12) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from tlendack-t1.amd.com (165.204.77.1) by SA0PR11CA0100.namprd11.prod.outlook.com (2603:10b6:806:d1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.17 via Frontend Transport; Fri, 13 Aug 2021 17:00:20 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6bce5eff-be55-45d7-dbbb-08d95e7bd5e9 X-MS-TrafficTypeDiagnostic: DM6PR12MB5535: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1417; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Z5HTomtymFVTmu4fZ5h4REqZZbJsO/VgEfAZoc7RxxTHii4xYzMYghE2G/djmL6z5ncpMekJtllsReLXD1Opx8ikmjHftat8V8SIdoFn70Aoy2Tx3jl0FWB4QBPBKVvK85S6exN363NEeD3mTZJS9eN+DWq0H4lcICxm9mfY5G+RWYIZ1qp3Pg3P/VO2UQPJOueymH7j+vnedPE+xIkvyqv2u47av/2QYafashGp+EJx0Ht1aAUKQubBxIiGvvr9ocsdoDbv3OM4j+lqHKGn3gpvy6U5BDb19QvrseLsa4hWXeuv/S/p0erTYoMMPEHkKhT8MmcbiymegA5mUZMinlCltm80Je/N1YAG7c2ln3yhxe82FECa5zBeu30KXWPagB3WbLfwXEFjNTGBmRcU2oaqsqyCmGWsAwayed8/k6PlWwZqqqmM3sfQV5yCqJ+X8GN9OJmRnDu7/5XBtLGIUhSlO9eyP+4Dw6Ov15Ydd0DIsCToOw0QbXNGqnHyM0uf9TxLJGGUHpQhLaKbu2vgPVosntgRnu/2kg200hx/QEIl0sVGBLhkc5a3H2pyJxTpLUdeXNzGLS1IeLF2IWGGqGlpUIS+jcujpF0KinNCqSyOYhXMmCRWz58pBxyO3az7Ph/+u9s8lTDj8OVHgBYuBbkbbzaKOZbuX/RvSdKByqjcJlNGeKX5pjmk6oWEzGjWq4qUA+8wDZvsjiI8kLikUg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR12MB5229.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(8936002)(508600001)(66556008)(66476007)(921005)(52116002)(66946007)(4326008)(36756003)(38350700002)(38100700002)(7416002)(7696005)(2616005)(956004)(186003)(5660300002)(2906002)(26005)(8676002)(316002)(6486002)(54906003)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: co/jy0FU9OZZPjQPiXPlHdwTIioZtB+0e7VWEGI9UYLUnE+4eh4wtxWPA1mGUXQIMesbYMFDDWCSgdc3l0pXWhKMTSrG4ocP9WWIFufkSnGNCJzZ/k9WYEG5PM04wTK7rPo0aqOuSJLZn/A5gSJcR1AO6gte755ENRmi6bn+NoTgDAntoVf1Y0O+xK1UT5sD8HQnKwq0BICObSKjcThZ1xnNHy5mZQUaqlL1XMkZ6aI8FJBz+of5XGXGWxmrV2MKxat4ySeKdyhNe4d/qJRJlLGaOElGmN5jiaF4JRcT2kusGpjbwfFaxMzz9akJxIbia4KdIC8MH3XTwny1g48OTmN0THOwxHiP1eyUx0yqcN+Z+xgsWKmeVoe96PzPvR6ez0V6vNJiFWVmdrzTmDKRMRATAaTDxGNfLBGPatac91jE6ux1wt9b/BE32r3y1KVnf2zi1F4DnJG4Is4AbXM8L0itrplb8fVBVamWiG0Re6LD9OpOdnC2fLAo6cU8BdN72xQY0V/bxKtK6EdW6fKXY3gGrBSccbJWizA/tB/JlZKH4LT1LZsf6Qu1OP15MKDdRihy8jpfdAwY4/ZA9yZBZ2uKi1HvEt2TlXpWWAs2EMaPJASFsHQme9KPDDw7l4vWE5D8EAEwxmGSkpjnXFWdCErEggUaB67A8z+PFbrfD7VjZr76R7nTdQESla+MiW+4yG2Feca/oQi4IyZ+vW17Q/6fVXKmPSunLfPvA3TnUn55UKZGHhn0iXqweP6y1dkSG8eK0ca533bxz90vtx8x7mrrD2MSpxvHVm8Kr4bN7v/tgQ1ECbZJ+y8wJVYy4QlHefwcFaTOJ4Kw2TFuCj3vBUVZ6CfxRXlFoJHXYzmkYm7qyU2sqmtpeVZKlwyK/hZnV9jr6q8IRlSxM4UKhhNL/1Y3JJOAwK6BInMInBGDc2/UwThZVWLj6UrCQpP19LuDkfP3PSapX2SqoffFbtTneOopIBtW5vp6oBd8OdyNxFW4c1PKG37t+5q10ZiUOm4572FByc77RCbdnyQUGWjrT8g6I7WFmORWQxfDiOHMiS+E8DDFm4nh8hLVGuiSruQ83IJj9XEHd6nWQaklUvnsPTWTcdaH0Bl48UTzwzOOCfJitN8sKAYqUZbF1IeETSLVbOdRHdts6Q8AzDJxg6fVFs1DsMeHWUoj/ErnXF5B7nHqZhNfwB/BEG16+r/GGDm5UabMJ8TNEcr0mpLl8xX6GYABOhNUSZ8SLnBnaFPkHRKRJUlm5KWezfEJanVgyLCRZKPIsQIOLPpLSw3uAns76i+NOhAiwKfoks2jj8yNePnJb5peZWngkO+Bm1KiuiXj X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6bce5eff-be55-45d7-dbbb-08d95e7bd5e9 X-MS-Exchange-CrossTenant-AuthSource: DM4PR12MB5229.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2021 17:00:21.3463 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: WqOAYCkbdSu6ytyOLP1tIRY5qvQs3lxBTGCT65o9ueikarKZb5dV+FsMz+OhuldzCP+naJUQwedpRL3RGpKHHQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB5535 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Introduce a powerpc version of the prot_guest_has() function. This will be used to replace the powerpc mem_encrypt_active() implementation, so the implementation will initially only support the PATTR_MEM_ENCRYPT attribute. Cc: Michael Ellerman Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Signed-off-by: Tom Lendacky Acked-by: Michael Ellerman --- arch/powerpc/include/asm/protected_guest.h | 30 ++++++++++++++++++++++ arch/powerpc/platforms/pseries/Kconfig | 1 + 2 files changed, 31 insertions(+) create mode 100644 arch/powerpc/include/asm/protected_guest.h diff --git a/arch/powerpc/include/asm/protected_guest.h b/arch/powerpc/include/asm/protected_guest.h new file mode 100644 index 000000000000..ce55c2c7e534 --- /dev/null +++ b/arch/powerpc/include/asm/protected_guest.h @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Protected Guest (and Host) Capability checks + * + * Copyright (C) 2021 Advanced Micro Devices, Inc. + * + * Author: Tom Lendacky + */ + +#ifndef _POWERPC_PROTECTED_GUEST_H +#define _POWERPC_PROTECTED_GUEST_H + +#include + +#ifndef __ASSEMBLY__ + +static inline bool prot_guest_has(unsigned int attr) +{ + switch (attr) { + case PATTR_MEM_ENCRYPT: + return is_secure_guest(); + + default: + return false; + } +} + +#endif /* __ASSEMBLY__ */ + +#endif /* _POWERPC_PROTECTED_GUEST_H */ diff --git a/arch/powerpc/platforms/pseries/Kconfig b/arch/powerpc/platforms/pseries/Kconfig index 5e037df2a3a1..8ce5417d6feb 100644 --- a/arch/powerpc/platforms/pseries/Kconfig +++ b/arch/powerpc/platforms/pseries/Kconfig @@ -159,6 +159,7 @@ config PPC_SVM select SWIOTLB select ARCH_HAS_MEM_ENCRYPT select ARCH_HAS_FORCE_DMA_UNENCRYPTED + select ARCH_HAS_PROTECTED_GUEST help There are certain POWER platforms which support secure guests using the Protected Execution Facility, with the help of an Ultravisor