Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp3966040pxu; Tue, 20 Oct 2020 05:21:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxx6Y+vgS3xAStQSTVOTRlrboD2yoiJOWCbz1trbqMXGdKdceE5l9dgwW7jdl8yyWdRQrlN X-Received: by 2002:a17:906:364d:: with SMTP id r13mr2704650ejb.521.1603196506483; Tue, 20 Oct 2020 05:21:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603196506; cv=none; d=google.com; s=arc-20160816; b=C762mlTswstAtXQF4sbZFFd7weiYayLEbe+hnPU4cUlODZ0/34UNRBG6yJu/XWSE5p /cE8Wv7lNa+dCUgYVzVND5bCqUrzI6MJTHwkC4HtVa634V3iLLKCYt8vn8PpODR4lwuP 2DnlxqACSQjPCLxhsT0wAOBfVNfdJJCHinqeK4BsFnJlfGQiTiZGZMgdnj0EGw/Gz1Tg Wcm06YlMft6H4PE3hVli3mg5ZTBRh5/2KDXcmkPp2OuK/EvxKLevIDgpBg6S8BSNNWN0 xGoi8ASwxSbYY9qhqQTtNUiO2bTlqs32o1hMAGRTdgC+yfbELGcsyybWF5yCnocJPpn5 P83g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=gl6yffbQ9r+QAiRXMg6GOhRwaULdYiHaklNgNURnfyo=; b=RnmRc8c7l6tp6ucroxPB0er1yaqrOymefEImhS3Kq2C4xziTMMRGsuKbn17PQcqiMT Ybix2r1tOJPkSKuP9sGObrQ3rI4wJinR/dkIqrve8htXMI1Pa14KyXaxlUzj3mbS9qc5 g4cfKJXSrwNJLFEOppTv/KSsPh460kOuaTmPWowNwFEY8GOrOrf35D01qMWFBS9BhqhG N10qtU/M7zMG+UvfEKtYXD2sYCW0+jP1meb50bjUoj6P9DXnJ3mKvxWHFag4xXiHGogc ptAbSjjiwzTFfmbKO2Tqo/az7Cd+itoYHS0nYkHzW/OFFBxMgqiBCdcW7IDf1RzIr1BO S+OA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cx23si1012358edb.541.2020.10.20.05.21.24; Tue, 20 Oct 2020 05:21:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394352AbgJTMTZ (ORCPT + 99 others); Tue, 20 Oct 2020 08:19:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394298AbgJTMTI (ORCPT ); Tue, 20 Oct 2020 08:19:08 -0400 Received: from theia.8bytes.org (8bytes.org [IPv6:2a01:238:4383:600:38bc:a715:4b6d:a889]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D338C061755 for ; Tue, 20 Oct 2020 05:19:08 -0700 (PDT) Received: from cap.home.8bytes.org (p549add56.dip0.t-ipconnect.de [84.154.221.86]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by theia.8bytes.org (Postfix) with ESMTPSA id 92F12272; Tue, 20 Oct 2020 14:19:05 +0200 (CEST) From: Joerg Roedel To: x86@kernel.org Cc: Joerg Roedel , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Kees Cook , Arvind Sankar , Martin Radev , Tom Lendacky , linux-kernel@vger.kernel.org Subject: [PATCH v2 0/5] x86/sev-es: Mitigate some HV attack vectors Date: Tue, 20 Oct 2020 14:18:51 +0200 Message-Id: <20201020121856.19427-1-joro@8bytes.org> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joerg Roedel Hi, here are some enhancements to the SEV(-ES) code in the Linux kernel to self-protect it against some newly detected hypervisor attacks. There are 3 attacks addressed here: 1) Hypervisor does not present the SEV-enabled bit via CPUID 2) The Hypervisor presents the wrong C-bit position via CPUID 3) An encrypted RAM page is mapped as MMIO in the nested page-table, causing #VC exceptions and possible leak of the data to the hypervisor or data/code injection from the Hypervisor. The attacks are described in more detail in this paper: https://arxiv.org/abs/2010.07094 Please review. Thanks, Joerg Changes to v1: - Disable CR4.PGE during C-bit test - Do not safe/restore caller-safed registers in set_sev_encryption_mask() Joerg Roedel (5): x86/boot/compressed/64: Introduce sev_status x86/boot/compressed/64: Add CPUID sanity check to early #VC handler x86/boot/compressed/64: Check SEV encryption in 64-bit boot-path x86/head/64: Check SEV encryption before switching to kernel page-table x86/sev-es: Do not support MMIO to/from encrypted memory arch/x86/boot/compressed/ident_map_64.c | 1 + arch/x86/boot/compressed/mem_encrypt.S | 14 +++- arch/x86/boot/compressed/misc.h | 2 + arch/x86/kernel/head_64.S | 14 +++- arch/x86/kernel/sev-es-shared.c | 26 +++++++ arch/x86/kernel/sev-es.c | 20 ++++-- arch/x86/kernel/sev_verify_cbit.S | 91 +++++++++++++++++++++++++ arch/x86/mm/mem_encrypt.c | 1 + 8 files changed, 160 insertions(+), 9 deletions(-) create mode 100644 arch/x86/kernel/sev_verify_cbit.S -- 2.28.0