Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp714472pxb; Fri, 8 Jan 2021 16:49:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJwheU7FzfdGTimwrctlDrTHY/Eo6d7l5t6EzW3cqyOoV+5wyWfJWs1YStPNyknIl7zIdTFy X-Received: by 2002:aa7:d5d2:: with SMTP id d18mr7257372eds.126.1610153376737; Fri, 08 Jan 2021 16:49:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610153376; cv=none; d=google.com; s=arc-20160816; b=b2JvXRsH75X3CS8oPyoot3pBGzKwnmx7i345u9folrJe6fHjVhKNlA2cqaCausK8sz COEoLN9xvJpvIBa2ZPEMTJiiDV5ChZo6vdtlblJ/W8mJpDbsprvONl+6V6ei02NNwU7T 7dZOQho2S1/0aCXev+GhuAj3bli1kQ02sFSvRC+s0JPwVH5bDSiX3KEPVIRCeU5k5VwH XQn9ytg0geU2GIqmYJ5sQjZdIJzoRaSmYou237bRKbzKnSGSobYcdAVQbTZcu9Mw1b5w RlRc593wEdQjfqSng8XgPUhbhaSiQ2FAzVU+uN/faQNwvEA5Nl8LcOPBJo8T+qEz79v6 VHZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :reply-to:sender:dkim-signature; bh=8hF52DFU9DtjJAeBrt6aHyP3PJDWIayV3uFwaqHlzLg=; b=yOuY/9Pd3vRXz5BSVzwKyVz6I69gUJUtQgf8NsoYhMlPBgPLHOt+jFf4vP3IhugGNJ 73lpSQOanXaBXEIGAGciHy4Xl1+NVWT6luBOyobveP7QtKW8BP5ohXaFR3cICQ5OrANH 6wTZ9N8Md8RHrXV42YSTSHSqG2F/+FrpXHpd/RQuZh7QjjhU2WRfE9XBmpeSL8+w6KIu WsHZLPeuKlX+ZAVGH7jH9zhWZZQ5upqZAZjuyDdwGPM2NmuOtsbpku38ApGk+mH8nMIb x0Jbsl1iYw/GMLpdvheWLGHYGBZIT0aIGq0+BwJDGSQG3OWUURu2069LOps80Gr/6Zh/ bsLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=nnJNRLdo; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cx27si3957108edb.264.2021.01.08.16.49.13; Fri, 08 Jan 2021 16:49:36 -0800 (PST) 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; dkim=pass header.i=@google.com header.s=20161025 header.b=nnJNRLdo; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726447AbhAIAsQ (ORCPT + 99 others); Fri, 8 Jan 2021 19:48:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726120AbhAIAsP (ORCPT ); Fri, 8 Jan 2021 19:48:15 -0500 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFEF0C061574 for ; Fri, 8 Jan 2021 16:47:35 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id e68so17351104yba.7 for ; Fri, 08 Jan 2021 16:47:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:reply-to:date:message-id:mime-version:subject:from:to:cc; bh=8hF52DFU9DtjJAeBrt6aHyP3PJDWIayV3uFwaqHlzLg=; b=nnJNRLdoyQB+0+OUl0304jaKmajIHLmQloL2/KK9Y3OsTzvygUbzjY5k31ZSRafzFK KJ/6xsZ2Ma2pvNu8v06qwlJh2MI52snKKjQEVqJDvgSHGCLTJlvj+TqDhH7d8q16BK3I AbSYAPAlSKeYL88mWMCBWhPfgQYAs5zM9qpJRRQn/pGA0nmyYlgKTTiogqAQ8bckZsXN cuI6wPg4fvocfcfUoet8mDHzJTPWbYphlCrKwZwPYiksDD27EQ78TXGwh0JtreXgPj+u A1f/SbcPys2KDUyPMYdo8eGa1eKB4t4q0g8mYZzvn6mBkxcacmQmKZgYuTc5J+oUlvm1 J/8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:reply-to:date:message-id:mime-version :subject:from:to:cc; bh=8hF52DFU9DtjJAeBrt6aHyP3PJDWIayV3uFwaqHlzLg=; b=e7e6iisPG9kc5uQmuPuoD1jZS/1o6MLCVfEWpEM2T+ioWGSkK42b94YaRJLiudwSel //GHXJSsScGxhL8R0fz9bl4yiDsiFInK/uHd8hhH7lbaPHBdGhZ0gRYDjh8FGj42emvJ xcMW/3PP8dZy42+jlR2hmG+5StI3INmWDNLoeiN5NbBZaCyk14XzwHDFTwzNkQZ50EEs Yln4CavltK6eptPeIPY1QIS4qRbX1j6MWyevY0gqooOWiyg0RQoml+zjvlkdWVXmzYHQ klZdbwFhNXm9w90OTeC7tbFE/b5QM69U5MyZvbl7SYgFl6GdTyfTZppoShPdJXQiTXp/ x2pg== X-Gm-Message-State: AOAM530jlyctWvFLBMlpYteDieMUm4cssnOkA7VK/3gdNPeizIraOc7I /ZekK2Cj01VaZ8N45kzbgufL3ziK0j0= Sender: "seanjc via sendgmr" X-Received: from seanjc798194.pdx.corp.google.com ([2620:15c:f:10:1ea0:b8ff:fe73:50f5]) (user=seanjc job=sendgmr) by 2002:a25:3d7:: with SMTP id 206mr9734090ybd.31.1610153254891; Fri, 08 Jan 2021 16:47:34 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 8 Jan 2021 16:47:01 -0800 Message-Id: <20210109004714.1341275-1-seanjc@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7-goog Subject: [PATCH 00/13] KVM: SVM: Misc SEV cleanups From: Sean Christopherson To: Paolo Bonzini , Dave Hansen , Andy Lutomirski , Peter Zijlstra Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Tom Lendacky , Borislav Petkov , Brijesh Singh Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Minor bug fixes and refactorings of SEV related code, mainly to clean up the KVM code for tracking whether or not SEV and SEV-ES are enabled. E.g. KVM has both sev_es and svm_sev_enabled(), and a global 'sev' flag while also using 'sev' as a local variable in several places. Based on kvm/master, commit 872f36eb0b0f ("KVM: x86: __kvm_vcpu_halt can be static"). Not super well tested, but AFAICT the feature detection is working as expected. Boris, this obviously touches on the KVM vs. kernel _cpu_has() stuff as well. My thought is that we can judge the SME/SEV features solely on whether or the kernel wants to dedicated a word for 'em, and hash out what to do with KVM at large in the SGX thread. Sean Christopherson (13): KVM: SVM: Free sev_asid_bitmap during init if SEV setup fails KVM: SVM: Zero out the VMCB array used to track SEV ASID association KVM: SVM: Move SEV module params/variables to sev.c x86/cpufeatures: Assign dedicated feature word for AMD mem encryption KVM: x86: Override reported SME/SEV feature flags with host mask x86/sev: Rename global "sev_enabled" flag to "sev_guest" KVM: SVM: Append "_enabled" to module-scoped SEV/SEV-ES control variables KVM: SVM: Unconditionally invoke sev_hardware_teardown() KVM: SVM: Explicitly check max SEV ASID during sev_hardware_setup() KVM: SVM: Move SEV VMCB tracking allocation to sev.c KVM: SVM: Drop redundant svm_sev_enabled() helper KVM: SVM: Remove an unnecessary prototype declaration of sev_flush_asids() KVM: SVM: Skip SEV cache flush if no ASIDs have been used arch/x86/include/asm/cpufeature.h | 7 +- arch/x86/include/asm/cpufeatures.h | 17 +++-- arch/x86/include/asm/disabled-features.h | 3 +- arch/x86/include/asm/mem_encrypt.h | 2 +- arch/x86/include/asm/required-features.h | 3 +- arch/x86/kernel/cpu/common.c | 3 + arch/x86/kernel/cpu/scattered.c | 5 -- arch/x86/kvm/cpuid.c | 2 + arch/x86/kvm/cpuid.h | 1 + arch/x86/kvm/svm/sev.c | 64 +++++++++++++------ arch/x86/kvm/svm/svm.c | 35 +++------- arch/x86/kvm/svm/svm.h | 8 +-- arch/x86/mm/mem_encrypt.c | 4 +- arch/x86/mm/mem_encrypt_identity.c | 2 +- .../arch/x86/include/asm/disabled-features.h | 3 +- .../arch/x86/include/asm/required-features.h | 3 +- 16 files changed, 88 insertions(+), 74 deletions(-) -- 2.30.0.284.gd98b1dd5eaa7-goog