From patchwork Wed Mar 7 16:50:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 10264517 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 BEFCA602C8 for ; Wed, 7 Mar 2018 17:04:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ACB8E2947F for ; Wed, 7 Mar 2018 17:04:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A146729498; Wed, 7 Mar 2018 17:04:14 +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 11A6C2947F for ; Wed, 7 Mar 2018 17:04:14 +0000 (UTC) Received: from localhost ([::1]:34412 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etcU8-0000YK-S9 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 07 Mar 2018 12:04:12 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50407) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1etcHm-0004pp-23 for qemu-devel@nongnu.org; Wed, 07 Mar 2018 11:51:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1etcHl-0008P1-2g for qemu-devel@nongnu.org; Wed, 07 Mar 2018 11:51:26 -0500 Received: from mail-bl2nam02on0087.outbound.protection.outlook.com ([104.47.38.87]:41344 helo=NAM02-BL2-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 1etcHk-0008OW-UK for qemu-devel@nongnu.org; Wed, 07 Mar 2018 11:51:25 -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=ii5qnKz/iLcENW5KZJcwoPpFtKugynXFvua4SaNG7iU=; b=F0D1oGpoTJBkHBULNx5mAOysn+zEd8Gs/w0pEOOY5tRw/catzTAxtPMJE3SVa+29cv3UGqy60uMZ+Oz40Fbe9iELlbsgYo0j3cFWmeame98qdWUh8fxjBWsr6836N2lTZNXcHtZkTkBhlI+nGb412KulMacoAp9dTmOTG/cc9RI= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Received: from wsp141597wss.amd.com (165.204.78.1) by SN1PR12MB0158.namprd12.prod.outlook.com (2a01:111:e400:5144::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.548.13; Wed, 7 Mar 2018 16:51:21 +0000 From: Brijesh Singh To: qemu-devel@nongnu.org Date: Wed, 7 Mar 2018 10:50:30 -0600 Message-Id: <20180307165038.88640-21-brijesh.singh@amd.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180307165038.88640-1-brijesh.singh@amd.com> References: <20180307165038.88640-1-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: SN4PR0501CA0095.namprd05.prod.outlook.com (2603:10b6:803:22::33) To SN1PR12MB0158.namprd12.prod.outlook.com (2a01:111:e400:5144::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 1ce19b9e-42c5-4d92-3b4e-08d5844ba7f5 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:SN1PR12MB0158; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0158; 3:464lrAms8FrefHjSnK1jPjUSIOlDIce2uG4XnkVF3zhzLWzK6pjNLEoUrxg+yDwLQFCzq8/cPQhX0/mqyEEItu/+/gKCGnC4daPTdhZRgwDkcfC4X0Ihi2eHx1pEaKMaZyCgXDjwLF6IfXeVRQ3aM+GrpymS29NTa7qTHl0XRCFEpwx81xNIXwAFb1MekDtfv4D+kDgZKdSCNdbUP4TlVe0bHjx4fAQ408Gox/sz6PHZqQ7n4s9khqdPIAT1pZxd; 25:sLFbG0dFdXxDAzVaxIsp0HNB3GjdklKGxkpOZ4/eBZxMfjnAO9AFtCEc7gQeu2zudbNAf//GGIq/ME8WZNNkB2tmFufxNYP07CSuOt8kOpnR/2Nyx5Jpa7lDEaY8Bnz/5dv+UsvL10OXNPDpDlW+MkRpYX92SxMrNP3ACV3eizZ0WHu01UYueqElKFn7aW+0vKW2Vlc/9ZqAHyFnuFyiSYB0SAkMv9zW+MUVjG2PyL5gpcDI2PzXOl8l7r3V/HitzN0ujxphzSnVqQ4EafbIJguQPEwZE9LcemM2s9SFIBsD5Y81tqh3n06vrrrgcDjnU5WyxSRDacWcRt7I2G/KFg==; 31:hOvXFW6vTdc4IJ+4whx4h6RrqZQ1DZdcASXBiBaKJMDoFPPqdmJKHq6XPlST7/gOtIXWC0bu++Ti61F7LqKthaISb3P/tYyZ4CooO5Ppo+8BfG48t3VrfEG3ZOJ7a3CJfrj2JlO5A04QJkArJ1DOYoKDx8+9NX2GCbdmg38lOZy01oh4lVhkSaOVfDKUYPrpbZvUmwzRrkOTDIAMCp3EZOVLhzIp028OwEilzvN/HaU= X-MS-TrafficTypeDiagnostic: SN1PR12MB0158: X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0158; 20:Wz0E3W+0gVO7HCGnr6dU+izvv/F/dN1klv6tNf+5VnNiJMl8tGqYklTSNcqbW18TqBoTAN2hfTajbWJWPPlB03yuONmzRXuxsOAqwdKOUgN/N6I7YdF9f37ZPvZPnvO5Za3Mp6sT66TSPZxUDgUKLljuzFp77I/NESi3Mag1LVeAqKzMgj0vKYuvVO9eafNcjAhatXC66B3sltePJGXOcbK4ZYdb2W0PWch9OckeuOuul+KGCZGec+5hylsSbZZXxwKmF2OqEBie1TSeyh+txXAbLzhAsBkCNrthnfDC0Gply9Uw+FODi27UJZ175/6WUCo3U30e++TJ50S59tYR4lkKqwmcvWwwWuiQ+qcOUmp9dgpU3bXqSQrfws5vwzQzpxxrPwHIQ5bljnLs0159lvKRZ8sakZjtBhdctuRPwIhx8IxfCq/w9s9tUMZH8LhCZmJF7SDZB2o4zBRTEqbF+IDUD6Rlq0pvddWTpLQN/1iMSLJjcCt84vOefFHp393K; 4:qGQJtNiTJ66n1FOofqTAb4SufwO4SUOHSPz8CKECjueovBulZlrIVubOLU59meiwQgWPanDaPJd6oU1cLRrxDH/szhZBOHaQQtSZJUnQse/Z+ijr6d867LKB5OXpuFGKnwNQAhATUMVpstqOE8QEE+PogekICQYyc4G29zVFCe/JwZjxFS3/FG8v8n5pubfhr1vwi+ax85GNuBJKWmGrjgbYzhtn+Wq2J9acxSCmRlsj/if0lXgkRvSkxzMmPY8cIjk8MiX9CEGDA5xK5rKwOLz1JtOa9rV4qxWTkgeVLBaYFzYJ0Vp+NV8JHA4Q0rhz 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)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(6072148)(201708071742011); SRVR:SN1PR12MB0158; BCL:0; PCL:0; RULEID:; SRVR:SN1PR12MB0158; X-Forefront-PRVS: 0604AFA86B X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(1496009)(39380400002)(39860400002)(376002)(346002)(396003)(366004)(189003)(199004)(53936002)(8666007)(2950100002)(6486002)(6666003)(6916009)(53416004)(3846002)(1076002)(6116002)(4326008)(54906003)(8656006)(2906002)(25786009)(59450400001)(386003)(68736007)(478600001)(48376002)(50466002)(105586002)(2361001)(2351001)(86362001)(66066001)(106356001)(47776003)(186003)(16526019)(51416003)(76176011)(52116002)(7696005)(26005)(16586007)(316002)(50226002)(8936002)(8676002)(81156014)(81166006)(36756003)(7416002)(97736004)(305945005)(7736002)(39060400002)(5660300001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0158; H:wsp141597wss.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A: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; SN1PR12MB0158; 23:C3NpQCTZpyp7yqooppYL7ob4ArqWpDN2SrgsoU4ps?= =?us-ascii?Q?17aaBHCU7MfiwfmLrgxWO8NzP7C4zF3h/zcA1CLoz7e8NF6jVl1Duk3m4OhW?= =?us-ascii?Q?n0TVNPbU4YZQYpCu3UQy9G3kD7iDkVk2gomLdbQaTtrp5iZmMQPP4WCIwLAz?= =?us-ascii?Q?yz9thqecO5yuU0nDZqcVl7zecR6rUzPphON/4UgCRPUNmeoKrCRALwDPRYRQ?= =?us-ascii?Q?IGp+xuvqauv53Gj6kKawnKKrpacY3wiJtHNLO06wki6fxssJaCl2bGNMP2Ii?= =?us-ascii?Q?+DpTZXy/3sx4HY4e4xLhYGusSSE/ucMLdcjCoCKjvCoFxapMM8THKaH4x2UO?= =?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xkwCNSDMW0tMdvfKNsThpY/8ta1N6p0EcBVAlxLHtyFX7OZGzcEJhlciVJdciWPLky9jd0/r5XH4UQW7Z5tDl88+Xf5mDY8xkpniT/1ON67GP+bZkuc81Oh5oc8kYQrUa94vkoQZmkl+ShJ72bkyrrIWEeijCARR/0lWiXHCiM7w36B2L3NAKaKlReaVHM1dE+QrSfwlEmPzIZBvYC7qcLVet6CfRYmnGuOju1Tl SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0158; 20:xkZDHJFKOyEwwsuYT3y9lGzxSkAhclGp8/rwSdI5TgcxvnxOpEwVjzGSSxhXUYV227adDhTETSTSebZnY+jE4x/p9A+uPLH6lzQbz+ZDL1qOPm/KRqnNcV7gfJdiOjGP1QQD+Z5HCLXcdXeKeQe/CPAdoihZ8v37cVte+EsAll5RpAj+NYu2wIUvA5h+WzA2KpzS8Sx2zn476qQNGJ3CzuKeI+TKPQ/MtnQQyU7bZISHLSNmhZBMP+goAE1H19BS X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Mar 2018 16:51:21.1354 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1ce19b9e-42c5-4d92-3b4e-08d5844ba7f5 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0158 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.38.87 Subject: [Qemu-devel] [PATCH v11 20/28] hw/i386: set ram_debug_ops when memory encryption is enabled 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 memory encryption is enabled, the guest RAM and boot flash ROM will contain the encrypted data. By setting the debug ops allow us to invoke encryption APIs when accessing the memory for the debug purposes. Cc: Paolo Bonzini Cc: Richard Henderson Cc: Eduardo Habkost Cc: "Michael S. Tsirkin" Signed-off-by: Brijesh Singh --- hw/i386/pc.c | 9 +++++++++ hw/i386/pc_sysfw.c | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 94cfd40ef2c8..2aed48cdf13d 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1360,6 +1360,15 @@ void pc_memory_init(PCMachineState *pcms, e820_add_entry(0x100000000ULL, pcms->above_4g_mem_size, E820_RAM); } + /* + * When memory encryption is enabled, the guest RAM will be encrypted with + * a guest unique key. Set the debug ops so that any debug access to the + * guest RAM will go through the memory encryption APIs. + */ + if (kvm_memcrypt_enabled()) { + kvm_memcrypt_set_debug_ops(ram); + } + if (!pcmc->has_reserved_memory && (machine->ram_slots || (machine->maxram_size > machine->ram_size))) { diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c index 73ac783f2055..845240f97293 100644 --- a/hw/i386/pc_sysfw.c +++ b/hw/i386/pc_sysfw.c @@ -181,6 +181,12 @@ static void pc_system_flash_init(MemoryRegion *rom_memory) error_report("failed to encrypt pflash rom"); exit(1); } + + /* + * The pflash ROM is encrypted, set the debug ops so that any + * debug accesses will use memory encryption APIs. + */ + kvm_memcrypt_set_debug_ops(flash_mem); } } }