From nobody Sun Feb 8 12:37:23 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1589215352; cv=none; d=zohomail.com; s=zohoarc; b=IzzW5I3bbHVJrP0qazFk2FJvyS2CzRtdZCFjhj1tbsRY8BukE7y3qg9EpyrlX0TPJUPUBQ1gR9aP7gmmxKkPM7ZONUwN1MCzOL5eyr2ui9s2wP2SHsOuc+gsIrwTGzQ2QwbmUpW8IYP9OR/IObvrDqQrpFUmi4An/Tzt/iuc71Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589215352; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aH7adHrbhSZVDuhZlkGy29bmhV/loEtJzBUdXLFpLjw=; b=TPgNYro0Oks7WB4EOM9qn/c3f3sdP+vu2tbq423s1/T9IBTA7CaS+Lm3Vcj6CfFX6NaQ1Y/jmAFNWnx2lpwtoLC2vYf0aRjl6puIKYdXydOukVgfuuAVapH/ZueXkr/bYbiPxT0R1NB3k3DpKg42AiwJLOJzvpS+EeUBBpuMjAc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1589215352832708.3030617124152; Mon, 11 May 2020 09:42:32 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-258-esTjYRl6OoK1u0_NLhCMVA-1; Mon, 11 May 2020 12:42:29 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 117608005AD; Mon, 11 May 2020 16:42:24 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DEB185C3E7; Mon, 11 May 2020 16:42:23 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 353954CA95; Mon, 11 May 2020 16:42:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 04BGgMgD015770 for ; Mon, 11 May 2020 12:42:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 07C951055539; Mon, 11 May 2020 16:42:22 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 040AF1055535 for ; Mon, 11 May 2020 16:42:22 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DEC981049842 for ; Mon, 11 May 2020 16:42:21 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-175-LRdm9dvsMI2nDTzCGRZ47w-1; Mon, 11 May 2020 12:42:17 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 04BGXOEW137476; Mon, 11 May 2020 12:42:15 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 30ws243js5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 May 2020 12:42:15 -0400 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 04BGXUlK138251; Mon, 11 May 2020 12:42:15 -0400 Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 30ws243jrc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 May 2020 12:42:15 -0400 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 04BGfSMx008220; Mon, 11 May 2020 16:42:12 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma03fra.de.ibm.com with ESMTP id 30wm569wsn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 May 2020 16:42:12 +0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 04BGgAPZ66519192 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 11 May 2020 16:42:10 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F0F014203F; Mon, 11 May 2020 16:42:09 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ACF5B42041; Mon, 11 May 2020 16:42:09 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.43.168]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 11 May 2020 16:42:09 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589215351; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=aH7adHrbhSZVDuhZlkGy29bmhV/loEtJzBUdXLFpLjw=; b=Fg7d2pcnRnV1maHpQ0BgfOaEB1dHmBmi71Kdl0NtSL/Zpgbd33r/MT04gLxBrFoZDjXzAv saGkR0MhtCvWaGPXfAS2E3YYo7A0eq6svn72OaZHePumtZb40hi6sEBnO8bi5JxpM1VXA8 rn5iCL53mbhdOYkkCS5sXf5SlYP3BYk= X-MC-Unique: esTjYRl6OoK1u0_NLhCMVA-1 X-MC-Unique: LRdm9dvsMI2nDTzCGRZ47w-1 From: Boris Fiuczynski To: libvir-list@redhat.com, mihajlov@linux.ibm.com, ppinatti@linux.ibm.com, berrange@redhat.com, borntraeger@de.ibm.com, brijesh.singh@amd.com, eskultet@redhat.com Subject: [PATCH 5/6] tools: secure guest check for AMD in virt-host-validate Date: Mon, 11 May 2020 18:42:00 +0200 Message-Id: <20200511164201.7954-6-fiuczy@linux.ibm.com> In-Reply-To: <20200511164201.7954-1-fiuczy@linux.ibm.com> References: <20200511164201.7954-1-fiuczy@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216, 18.0.676 definitions=2020-05-11_08:2020-05-11, 2020-05-11 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 suspectscore=0 bulkscore=0 adultscore=0 impostorscore=0 mlxscore=0 lowpriorityscore=0 malwarescore=0 mlxlogscore=999 priorityscore=1501 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005110130 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: danielhb413@gmail.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Add checking in virt-host-validate for secure guest support on x86 for AMD Secure Encrypted Virtualization. Signed-off-by: Boris Fiuczynski Reviewed-by: Paulo de Rezende Pinatti Reviewed-by: Bjoern Walk --- docs/kbase/launch_security_sev.rst | 7 ++++-- tools/virt-host-validate-common.c | 36 ++++++++++++++++++++++++++++-- tools/virt-host-validate-common.h | 1 + 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/docs/kbase/launch_security_sev.rst b/docs/kbase/launch_securit= y_sev.rst index fa602c7432..45166b3886 100644 --- a/docs/kbase/launch_security_sev.rst +++ b/docs/kbase/launch_security_sev.rst @@ -30,8 +30,11 @@ Enabling SEV on the host =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 Before VMs can make use of the SEV feature you need to make sure your -AMD CPU does support SEV. You can check whether SEV is among the CPU -flags with: +AMD CPU does support SEV. You can run ``libvirt-host-validate`` +(libvirt >=3D 6.4.0) to check if your host supports secure guests or you +can follow the manual checks below. + +You can manually check whether SEV is among the CPU flags with: =20 :: =20 diff --git a/tools/virt-host-validate-common.c b/tools/virt-host-validate-c= ommon.c index dd73bd0dea..67aa420d35 100644 --- a/tools/virt-host-validate-common.c +++ b/tools/virt-host-validate-common.c @@ -41,7 +41,8 @@ VIR_ENUM_IMPL(virHostValidateCPUFlag, "vmx", "svm", "sie", - "158"); + "158", + "sev"); =20 static bool quiet; =20 @@ -447,15 +448,19 @@ int virHostValidateSecureGuests(const char *hvname, virHostValidateLevel level) { virBitmapPtr flags; - bool hasFac158 =3D false; + bool hasFac158 =3D false, hasAMDSev =3D false; virArch arch =3D virArchFromHost(); g_autofree char *cmdline =3D NULL; static const char *kIBMValues[] =3D {"y", "Y", "1"}; + static const char *kAMDValues[] =3D {"on"}; + g_autofree char *mod_value =3D NULL; =20 flags =3D virHostValidateGetCPUFlags(); =20 if (flags && virBitmapIsBitSet(flags, VIR_HOST_VALIDATE_CPU_FLAG_FACIL= ITY_158)) hasFac158 =3D true; + else if (flags && virBitmapIsBitSet(flags, VIR_HOST_VALIDATE_CPU_FLAG_= SEV)) + hasAMDSev =3D true; =20 virBitmapFree(flags); =20 @@ -485,6 +490,33 @@ int virHostValidateSecureGuests(const char *hvname, virHostMsgFail(level, "Hardware or firmware does not provide " "support for IBM Secure Execution"); } + } else if (hasAMDSev) { + if (virFileReadValueString(&mod_value, "/sys/module/kvm_amd/parame= ters/sev") < 0) { + virHostMsgFail(level, "AMD Secure Encrypted Virtualization not= " + "supported by the currently used kernel"= ); + return 0; + } + if (mod_value[0] !=3D '1') { + virHostMsgFail(level, + "AMD Secure Encrypted Virtualization appears to= be " + "disabled in kernel. Add mem_encrypt=3Don " + "kvm_amd.sev=3D1 to kernel cmdline arguments"); + return 0; + } + if (virFileReadValueString(&cmdline, "/proc/cmdline") < 0) + return -1; + if (virKernelCmdlineMatchParam(cmdline, "mem_encrypt", kAMDValues, + G_N_ELEMENTS(kAMDValues), + VIR_KERNEL_CMDLINE_FLAGS_SEARCH_LAS= T | + VIR_KERNEL_CMDLINE_FLAGS_CMP_EQ)) { + virHostMsgPass(); + return 1; + } else { + virHostMsgFail(level, + "AMD Secure Encrypted Virtualization appears to= be " + "disabled in kernel. Add mem_encrypt=3Don " + "kvm_amd.sev=3D1 to kernel cmdline arguments"); + } } else { virHostMsgFail(level, "Unknown if this platform has Secure Guest support"= ); diff --git a/tools/virt-host-validate-common.h b/tools/virt-host-validate-c= ommon.h index 44b5544a12..3df5ea0c7e 100644 --- a/tools/virt-host-validate-common.h +++ b/tools/virt-host-validate-common.h @@ -38,6 +38,7 @@ typedef enum { VIR_HOST_VALIDATE_CPU_FLAG_SVM, VIR_HOST_VALIDATE_CPU_FLAG_SIE, VIR_HOST_VALIDATE_CPU_FLAG_FACILITY_158, + VIR_HOST_VALIDATE_CPU_FLAG_SEV, =20 VIR_HOST_VALIDATE_CPU_FLAG_LAST, } virHostValidateCPUFlag; --=20 2.25.1