From patchwork Sun Dec 29 18:33:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11312361 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B6B3E921 for ; Sun, 29 Dec 2019 18:35:11 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9358E20748 for ; Sun, 29 Dec 2019 18:35:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OU+4AHjq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9358E20748 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ildOB-0008OP-DO; Sun, 29 Dec 2019 18:34:07 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ildOA-0008OC-3t for xen-devel@lists.xenproject.org; Sun, 29 Dec 2019 18:34:06 +0000 X-Inumbo-ID: c5bc2eb6-2a69-11ea-a1e1-bc764e2007e4 Received: from mail-wr1-x443.google.com (unknown [2a00:1450:4864:20::443]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id c5bc2eb6-2a69-11ea-a1e1-bc764e2007e4; Sun, 29 Dec 2019 18:33:57 +0000 (UTC) Received: by mail-wr1-x443.google.com with SMTP id j42so30877131wrj.12 for ; Sun, 29 Dec 2019 10:33:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+T4GPsHUk9nuxqbVFm0EUaUmXOk2IzXkX+VVh/krqzU=; b=OU+4AHjqz/NAKuZI3VYv8fyUs7tnmNWY1e9EXbF6UpTk/q2Kfpj269wnHzHBSi+Ov8 ROJUPsowviVzxM2Pu3ThoKMOA60tSwm8xz1N5oby3XI3gx5viA4E+2eIYj52kFDDUs+M 4p8bKS1wStvjFBb/EuIHUI6ozSo7zfsmAu5ULUytySrLLQyAVzzOx1GCBHp5+ONNut7b BnmveNOhkmTjWSIOgd17iBaZq9KSEfNXHzld1Pu0yp89owZmjYfLVqoWrbz7C9jxqd8A 13mGnebQd84Cdeu5pUPBdpusgj+fGPAkcqUE/t4LGqD0/zvX4YXcsrBgrs1+NEjfJyow qE+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=+T4GPsHUk9nuxqbVFm0EUaUmXOk2IzXkX+VVh/krqzU=; b=pSEtyzsj/JH181F0SLHoBcV+lLp2bP4IzM7445regXASklLy/MXNAhrV/S+mGRu7BQ 2pMNehYpEqSPTqWN5zbxJgI/bWxKCvm9jYRfZUpzhW+Xm9QipgyfwXm+XNVZfU7EIMhe CZK8oJo3kQSQr4HbIpfBu4uCaElOiXIKlgn8srVi+sWEuewcBFTMWX7R7jk5vwrU9k2A 4G48jeu1duqZo2T9Sp+U/0rATv/6dK5MRPrbPv+NEo+nTgqICX6Gm9BGXDl8buPKXt8J 5xdUydTAtM1avrJ70XE6f0dRRCfVTjTUEZWIqyAVscQ+6mzmf7PQJ2NnIpuatUdMknQ/ xiTA== X-Gm-Message-State: APjAAAXJTzEZn8pm19vVqGRhVkSJasjKx1/4ujW6TFmUcLrLuhDmM4mj PNXnRNM1t4+qAX51ZJ8MEux9cdmtJlQ= X-Google-Smtp-Source: APXvYqw/YO/cDA3aZjfUEK+TEYTaZtNX+da0gMiZ1nJY681tg54LCSdhDnn212HH0uMckb6WNMu+Iw== X-Received: by 2002:adf:90e1:: with SMTP id i88mr59664807wri.95.1577644436007; Sun, 29 Dec 2019 10:33:56 -0800 (PST) Received: from localhost.localdomain (38.163.200.146.dyn.plus.net. [146.200.163.38]) by smtp.gmail.com with ESMTPSA id f207sm19667903wme.9.2019.12.29.10.33.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Dec 2019 10:33:55 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Sun, 29 Dec 2019 18:33:35 +0000 Message-Id: <20191229183341.14877-3-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191229183341.14877-1-liuwe@microsoft.com> References: <20191229183341.14877-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 2/8] x86/hyperv: detect absolutely necessary MSRs X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Wei Liu , Wei Liu , Paul Durrant , Andrew Cooper , Michael Kelley , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" If they are not available, disable Hyper-V related features. Signed-off-by: Wei Liu Acked-by: Jan Beulich --- xen/arch/x86/guest/hyperv/hyperv.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/xen/arch/x86/guest/hyperv/hyperv.c b/xen/arch/x86/guest/hyperv/hyperv.c index 2e70b4aa82..c6a26c5453 100644 --- a/xen/arch/x86/guest/hyperv/hyperv.c +++ b/xen/arch/x86/guest/hyperv/hyperv.c @@ -32,6 +32,8 @@ static const struct hypervisor_ops ops = { const struct hypervisor_ops *__init hyperv_probe(void) { uint32_t eax, ebx, ecx, edx; + uint64_t required_msrs = HV_X64_MSR_HYPERCALL_AVAILABLE | + HV_X64_MSR_VP_INDEX_AVAILABLE; cpuid(0x40000000, &eax, &ebx, &ecx, &edx); if ( !((ebx == 0x7263694d) && /* "Micr" */ @@ -57,6 +59,15 @@ const struct hypervisor_ops *__init hyperv_probe(void) ms_hyperv.max_vp_index = eax; ms_hyperv.max_lp_index = ebx; + if ( (ms_hyperv.features & required_msrs) != required_msrs ) + { + /* Oops, required MSRs are not available. Treat this as + * "Hyper-V is not available". + */ + memset(&ms_hyperv, 0, sizeof(ms_hyperv)); + return NULL; + } + return &ops; }