From patchwork Thu Mar 8 12:48:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 10268029 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DBFB560211 for ; Thu, 8 Mar 2018 13:04:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA6742987B for ; Thu, 8 Mar 2018 13:04:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE5AD29904; Thu, 8 Mar 2018 13:04:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2906C2987B for ; Thu, 8 Mar 2018 13:04:18 +0000 (UTC) Received: from localhost ([::1]:38539 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etvDW-0001Pt-38 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 08 Mar 2018 08:04:18 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59144) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etv0D-0005l2-Vn for qemu-devel@nongnu.org; Thu, 08 Mar 2018 07:50:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1etv0A-0004Mb-15 for qemu-devel@nongnu.org; Thu, 08 Mar 2018 07:50:34 -0500 Received: from mail-cys01nam02on0057.outbound.protection.outlook.com ([104.47.37.57]:52496 helo=NAM02-CY1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1etv09-0004MG-PY for qemu-devel@nongnu.org; Thu, 08 Mar 2018 07:50:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=GZqp8hzqvX3V4fCooOrd+RyAMjAOInWIbhjjBnxmOFs=; b=C0U9sFRoMffotyJXlOd/TR9trsEIHg6WTLtha0XfoZjDF/GcZzX4WG8lwvJo3TkNMC91NYMsWelEW9lrgfCbHXL00vKVbJ5BITuhYYMidQtpWRU5DCiVbYAplhzToOZJxS/fJC7ULFonSw7onFsD4wJ+Bh1bAIBdFblSp5Q9Emo= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Received: from wsp141597wss.amd.com (165.204.78.1) by DM2PR12MB0156.namprd12.prod.outlook.com (2a01:111:e400:50ce::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.548.13; Thu, 8 Mar 2018 12:50:24 +0000 From: Brijesh Singh To: qemu-devel@nongnu.org Date: Thu, 8 Mar 2018 06:48:58 -0600 Message-Id: <20180308124901.83533-26-brijesh.singh@amd.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180308124901.83533-1-brijesh.singh@amd.com> References: <20180308124901.83533-1-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: BN6PR14CA0031.namprd14.prod.outlook.com (2603:10b6:404:13f::17) To DM2PR12MB0156.namprd12.prod.outlook.com (2a01:111:e400:50ce::19) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 67735748-508f-4926-4d21-08d584f32aa5 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:DM2PR12MB0156; X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0156; 3:/b3XXkqYxdE4zMB/vR724sYUSa7ovAGLr0M0JY3JbXjS6PW9i2GdJBhSFQ09DKEnmuSHSzT+vMbTlyvAnEQAqsK1yoJ34yLflHsIB2XMmi+MULnq7EWBbZ+85yDMG55Pl8PGQanrEKzjGa/DHCIJ/svK27M1SyeT2oArafnm/Samr++MQv2NXXrNaoJQAif5AV9HpcuM2/86JHnvbXkhdci9Dz5oh8SbaXz602YYM40bzLaZLymij6J5FxsTqjRd; 25:0xQzS2UCW9HkvqTETr6A+oNHUWbGZVE5TzRxrC+RktoLY8LHLwP6LQ7REf7fjw44JOn7NDtIbStKW7SmkOo4Wm2jnZBDlSTDZ4+iTs7mXm+fXXnNdWpdt+oa051HkMVDVAOGsT4UFsqdOAQjMJg9ivyanN9if9cCyJ3JvWqYWfez1LE9QnjCBvUwhoG/foLRBXzr4o0/ARZ13zG0VchoEBrKJmWHqWcPb/1vYcdlBD2UDMVHyojNzi/LU23/MclGldqX+LDohccgl2pCsgLMhR1hy16PnL1L3GBbMlrUjuDjop1rrbmIsxITJwNGnkWWSgKV2gtgSbrFUtVI6IzZSQ==; 31:TVXokP7sUhfLBz8EVR8uSbnlaF+zfCfEFRxvgRPS44ipBpiYhZKP/i40gu9dnI5hYPwxE4515S9Pq6Umpf0HQjk8biL/wUwiQO2ZKByb1s7KisyjInRxxEq+F2EMV7Ra0Nf1eNuUsHdxsWKReaBtdH2pxdesprbfwO5PHKea9ysFe117+Pbg1xD/DpXeHWvioubJfHGoKFw7Z+qcZlCCCRdwR3B4+5SQyz8vfy0C+aQ= X-MS-TrafficTypeDiagnostic: DM2PR12MB0156: X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0156; 20:WxKPFF7Mied+CHWK0W4L9rn0KrPd2o7zed3BaIa/OUu9753WaeiiiUjnfbuzbj1Nlvr5Vpa43msUCMCLv4UnlQwIdJV1rOhs84DB2CTRNhYomKph24TIZB7nSsYr+UTHta/aD2F2yj2P/4V3CaDXW20mD/JonUeDeshi/dmrb1dQFRRduKstHWsKlNTX/H1NJKrRTKY0R90u7riSolibfwJ5FeV5J36i1rXGamxUrC4BGGSVuN8I3fr1sFvXFsFBddBM9kFLKb/Kj8pvGiWq17Y8dGSCtQC0GyrgJr6jw+gCFQOu5oTNzoMxXwy2SqpRSf9pB+3fnnqMNGe0snGsKrwut0iMR7rBOU4Y4RTDgxd7/9onNdvbmMQaOcZRqQRcfdbRRQ53terhvmoD+Sf4qRa8/stoxnZo8IcCHJaJxNLiowKf2nx2mq9ReIXA9F/f5LztTbtI+F/S1w0QjGmipUpm6wPSmjDkx8zit1/MWLYNYVWC2JuMwJZoDe51zCgr; 4:OhewfQ/cFvGrtDIZoOzKItSglhykI7tf1fu9egNvE5MIsPwLJZalT+JFSyP2hjqrKxNl08KJf3eQkWaQIoody08wOwrzWebVeT0fWwRcDmN3OoRciYAr5eprqzOTZu6mn7rPq60AI2Sl3533YpCDDTiYcs0poJ9M0B9hQENg+x/hJvxXw5jyIxRPCM0AfEoM1/2GpOoW0Odv+2z7jnhkNEXft6+KdDaEXnj5Y/yr5cTh/II84Ao+et6DtzgLq9e+h1mtOLIS+x3h0EoO2HGZ3nS46EnvtSnyWsTZVF3Bd8SE3+87NExVXNQgFwoIBzsl X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040501)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3231220)(944501244)(52105095)(3002001)(6055026)(6041288)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(20161123558120)(20161123562045)(6072148)(201708071742011); SRVR:DM2PR12MB0156; BCL:0; PCL:0; RULEID:; SRVR:DM2PR12MB0156; X-Forefront-PRVS: 060503E79B X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(1496009)(39380400002)(39860400002)(376002)(396003)(346002)(366004)(199004)(189003)(50226002)(53936002)(6306002)(2950100002)(6916009)(2906002)(2361001)(6666003)(2351001)(106356001)(81156014)(53416004)(8676002)(81166006)(7736002)(36756003)(305945005)(8936002)(105586002)(48376002)(50466002)(68736007)(97736004)(47776003)(66066001)(25786009)(4326008)(39060400002)(6486002)(7416002)(5660300001)(3846002)(478600001)(76176011)(51416003)(7696005)(52116002)(6116002)(16586007)(16526019)(186003)(26005)(1076002)(8656006)(386003)(54906003)(86362001)(316002)(59450400001)(8666007); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR12MB0156; H:wsp141597wss.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR12MB0156; 23:5Lbwmh9XS26i6T9diORh8UUEANsN7h/118RpyijFA?= =?us-ascii?Q?ddiGrw9GB/aiUZwselr8RADXhaINv1pWoT6GNeM/NeScnK+bvygYaHaGQMCa?= =?us-ascii?Q?dpD8yrETiUnWAdoLoJ8SXWImZerWQoWWl/KzHV6ryIrxUxT2qzH94wBnkB3E?= =?us-ascii?Q?RPBOBQ3EPLbThZmhxN0vttcv6LTCtmyIHjPLw9TEtHGCyH5lSsuXvUaDBRJ2?= =?us-ascii?Q?cBqoHV8jHCMmlZmpZLAq1DKi6+t/oSROiXd47uSNP45skmSHLiEhfZjUlyFi?= =?us-ascii?Q?Jp2/acmgREJKORMfq8sS8kajceBd4CFJmxr4x1G/j90Xo2mI14TUGpH4p98H?= =?us-ascii?Q?akk21W8S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blUu9f1uPn3YdioyXD1KigXbAAeipt4jhXyVnHIQEVr0X6cs3ClMkqHmA0CeZetVVJnMpCqxb7FOQmFJBi12ZvFdRQiEhE1szruPtPFZSmMSEUfjwnlH9zDpnjO/gmrAUBc0xdFJFa8brIahLEnsbjcDYuMeQoUhtgD5AQRsL9F7tjy0ZTVl6p50Hy09V0I4w60kIj9/jr/Ba1QAOXdKdqdkr+Q6W5lK9WqFVeqTZ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR12MB0156; 20:6S1N41W0swYsXYWjF+dRcHXiFym0yC8TkrkIp+iFNcvThumf9m2ED/qkfvXRdj2+D0kPOvEglPV8UoVS1HahDF3NgpXc1CfvGjr4mLUpj+kED3LZYtE9SmsUGqUjqlFF6kYPWgRiWC+pIc1NYqRQNMa1zQcSGjFh3omIbLMN8sJ8/6GtyeMr88VbWOlAPhdcx3iVO0QlwoLEgL2tenD4ZoE35wMkk0jfvfdPxx86MXP1uyptqIJiUXb4NkaB/Qbw X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2018 12:50:24.9563 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 67735748-508f-4926-4d21-08d584f32aa5 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0156 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.37.57 Subject: [Qemu-devel] [PATCH v12 25/28] cpu/i386: populate CPUID 0x8000_001F when SEV is active X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Brijesh Singh , kvm@vger.kernel.org, "Michael S. Tsirkin" , Stefan Hajnoczi , Alexander Graf , "Edgar E. Iglesias" , Markus Armbruster , Bruce Rogers , Christian Borntraeger , Marcel Apfelbaum , Borislav Petkov , Thomas Lendacky , Eduardo Habkost , Richard Henderson , "Dr. David Alan Gilbert" , Alistair Francis , Cornelia Huck , Richard Henderson , Peter Crosthwaite , Paolo Bonzini Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP When SEV is enabled, CPUID 0x8000_001F should provide additional information regarding the feature (such as which page table bit is used to mark the pages as encrypted etc). The details for memory encryption CPUID is available in AMD APM (https://support.amd.com/TechDocs/24594.pdf) Section E.4.17 Cc: Paolo Bonzini Cc: Richard Henderson Cc: Eduardo Habkost Reviewed-by: Eduardo Habkost Signed-off-by: Brijesh Singh --- target/i386/cpu.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 2c04645ceac9..647f792ba123 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -26,6 +26,7 @@ #include "sysemu/hvf.h" #include "sysemu/cpus.h" #include "kvm_i386.h" +#include "sev_i386.h" #include "qemu/error-report.h" #include "qemu/option.h" @@ -3612,6 +3613,13 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, *ecx = 0; *edx = 0; break; + case 0x8000001F: + *eax = sev_enabled() ? 0x2 : 0; + *ebx = sev_get_cbit_position(); + *ebx |= sev_get_reduced_phys_bits() << 6; + *ecx = 0; + *edx = 0; + break; default: /* reserved values: zero */ *eax = 0; @@ -4041,6 +4049,11 @@ static void x86_cpu_expand_features(X86CPU *cpu, Error **errp) if (env->features[FEAT_8000_0001_ECX] & CPUID_EXT3_SVM) { x86_cpu_adjust_level(cpu, &env->cpuid_min_xlevel, 0x8000000A); } + + /* SEV requires CPUID[0x8000001F] */ + if (sev_enabled()) { + x86_cpu_adjust_level(cpu, &env->cpuid_min_xlevel, 0x8000001F); + } } /* Set cpuid_*level* based on cpuid_min_*level, if not explicitly set */