Received: by 10.223.164.202 with SMTP id h10csp618804wrb; Sun, 26 Nov 2017 08:42:30 -0800 (PST) X-Google-Smtp-Source: AGs4zMYqnzqqSFNyuCWGcUbuswg6onRBXafJ0w5RGj9r/RMlJabIbkxpmGVj15D6ScVsNxWgnBTj X-Received: by 10.84.236.12 with SMTP id q12mr35529332plk.314.1511714550795; Sun, 26 Nov 2017 08:42:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511714550; cv=none; d=google.com; s=arc-20160816; b=m/YkbcubIl6HLiw06NDVCIeJATFknzr0Tiviw25CrHp4AinNCKBawU+Y7vYAitKoS5 QRmCfL2xs6iTJBeZJjyd3BlpRwLohW8FVOYdxzDhYCtieG6cIP5W+lN0F61UOjcd3s55 XQcugk0W8RPyNgNas/n5XBYr3kTwgzeEwcnnt94VTRCcVNdehmFdAybt4qOkFs0bjl0o eKrkReIQgZQ1aE9JJkFKNZNGpAIIipsWMS9CPEW7I/DTmn0cFVemMIJHRV/PI+QxyEUk jgP+OrlQ8R0Fc9yiLKmv3wjcYcErN9ZILDdA/RciKiXdDeK9SqKkIlatsaWR0c41Hn5X yMAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=VXPpkTMJjwNk/dSSpuU7JX1q3aRx+OQwg7T5/3KebNk=; b=K2AXZfI0+yCVmR48I9xlBZ7DGy8ABOVBQTk9/vCM2ie7RS0el5eCtOTFCp55QVn3EH EtE8/qOQmtL2stghQ24tIP3aERMfnu1sNFwK3IANyVocbWfN8OIlZ8Sp1rOMTAXV+zDO pkV8N6qx3iQga95MPpfOWgxkkGF+j9DHhgE7M+WQ6daN6mHPocagV//E8W/7RlwRfON1 J/w2kPwhMNzuh2EiPhkO1aR8AVmdZaqhQx3aQ2ssBavBNOSTV4Ipka61A+aq9502ybjU Dv62DEOIM71l2nw48zIVxOlXs2oXLOjWbbyVQU2ddHUhTvWqoo+lraDhwR9EgePZB4Cx 9T/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b=Q3HlgZQv; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f67si21311304pgc.640.2017.11.26.08.42.19; Sun, 26 Nov 2017 08:42:30 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b=Q3HlgZQv; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752273AbdKZQlm (ORCPT + 79 others); Sun, 26 Nov 2017 11:41:42 -0500 Received: from smtp-fw-6001.amazon.com ([52.95.48.154]:40343 "EHLO smtp-fw-6001.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751969AbdKZQlj (ORCPT ); Sun, 26 Nov 2017 11:41:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1511714499; x=1543250499; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=VXPpkTMJjwNk/dSSpuU7JX1q3aRx+OQwg7T5/3KebNk=; b=Q3HlgZQvpYA5EATWZMRnCsQISBLfJi0PrNG6cOPPZVVSAY8qXZ3SQITu mtEeAwvjaIqkpXkbWu1ZBYrg4ZqJl/JL538SNsg45yB0J9hm+QTioTbwf rs4GYPkYutt+d2qCiFsnu1gHPhrqOgzhowAN0qs8fF8B2nOcFqSqXIMfN M=; X-IronPort-AV: E=Sophos;i="5.44,459,1505779200"; d="scan'208";a="320851156" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-2a-53356bf6.us-west-2.amazon.com) ([10.43.8.6]) by smtp-border-fw-out-6001.iad6.amazon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 26 Nov 2017 16:41:31 +0000 Received: from uf8b156e456a5587c9af4.ant.amazon.com (pdx2-ws-svc-lb17-vlan3.amazon.com [10.247.140.70]) by email-inbound-relay-2a-53356bf6.us-west-2.amazon.com (8.14.7/8.14.7) with ESMTP id vAQGfRYU107333 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 26 Nov 2017 16:41:28 GMT Received: from uf8b156e456a5587c9af4.ant.amazon.com (localhost [127.0.0.1]) by uf8b156e456a5587c9af4.ant.amazon.com (8.15.2/8.15.2/Debian-3) with ESMTP id vAQGfQiY008870; Sun, 26 Nov 2017 17:41:26 +0100 Received: (from sironi@localhost) by uf8b156e456a5587c9af4.ant.amazon.com (8.15.2/8.15.2/Submit) id vAQGfQ4a008859; Sun, 26 Nov 2017 17:41:26 +0100 From: Filippo Sironi To: pbonzini@redhat.com, rkrcmar@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Filippo Sironi Subject: [PATCH 2/2] KVM: x86: Allow userspace to define what's the microcode version Date: Sun, 26 Nov 2017 17:41:22 +0100 Message-Id: <1511714482-3273-2-git-send-email-sironi@amazon.de> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1511714482-3273-1-git-send-email-sironi@amazon.de> References: <1511714482-3273-1-git-send-email-sironi@amazon.de> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ... that the guest should see. Guest operating systems may check the microcode version to decide whether to disable certain features that are known to be buggy up to certain microcode versions. Address the issue by making the microcode version that the guest should see settable. The rationale for having userspace specifying the microcode version, rather than having the kernel picking it, is to ensure consistency for live-migrated instances; we don't want them to see a microcode version increase without a reset. Signed-off-by: Filippo Sironi --- arch/x86/kvm/x86.c | 23 +++++++++++++++++++++++ include/uapi/linux/kvm.h | 3 +++ 2 files changed, 26 insertions(+) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 925c3e29cad3..741588f27ebc 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -4033,6 +4033,29 @@ long kvm_arch_vm_ioctl(struct file *filp, } u; switch (ioctl) { + case KVM_GET_MICROCODE_VERSION: { + r = -EFAULT; + if (copy_to_user(argp, + &kvm->arch.microcode_version, + sizeof(kvm->arch.microcode_version))) + goto out; + break; + } + case KVM_SET_MICROCODE_VERSION: { + u32 microcode_version; + + r = -EFAULT; + if (copy_from_user(µcode_version, + argp, + sizeof(microcode_version))) + goto out; + r = -EINVAL; + if (!microcode_version) + goto out; + kvm->arch.microcode_version = microcode_version; + r = 0; + break; + } case KVM_SET_TSS_ADDR: r = kvm_vm_ioctl_set_tss_addr(kvm, arg); break; diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h index 282d7613fce8..e11887758e29 100644 --- a/include/uapi/linux/kvm.h +++ b/include/uapi/linux/kvm.h @@ -1192,6 +1192,9 @@ struct kvm_s390_ucas_mapping { #define KVM_S390_UCAS_UNMAP _IOW(KVMIO, 0x51, struct kvm_s390_ucas_mapping) #define KVM_S390_VCPU_FAULT _IOW(KVMIO, 0x52, unsigned long) +#define KVM_GET_MICROCODE_VERSION _IOR(KVMIO, 0x5e, __u32) +#define KVM_SET_MICROCODE_VERSION _IOW(KVMIO, 0x5f, __u32) + /* Device model IOC */ #define KVM_CREATE_IRQCHIP _IO(KVMIO, 0x60) #define KVM_IRQ_LINE _IOW(KVMIO, 0x61, struct kvm_irq_level) -- 2.7.4 From 1586583973901671808@xxx Tue Dec 12 13:13:06 +0000 2017 X-GM-THRID: 1586583973901671808 X-Gmail-Labels: Inbox,Category Promotions,HistoricalUnread