Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp330583ybi; Tue, 16 Jul 2019 21:25:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqxfgPO5Thag+6064sYZ/NaVOUleCB82nH2ppcELcLPiK6XYXjDHi684evd6VfGTSivh2S0C X-Received: by 2002:a17:902:704c:: with SMTP id h12mr38737573plt.318.1563337510142; Tue, 16 Jul 2019 21:25:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563337510; cv=none; d=google.com; s=arc-20160816; b=PWUZOqP6r+odxTv5FvUwsI4ZIs5AbAIo0Fiz5cs69/soN+ecrnyd+y5NmNTh2qCZMC Pvk+n0okhAd26vFUlKrMvYypJXVLvrKAWBs6E47wYCsSnVubyCJ2mufbLQWBLC7/FRLM hq2Cx2yaxeFc8MBXG6PFNjY+mAEV1CFD9xNoq/0RSV/cJsNAsEu7Lky7xmYJrSXAg09B eYbTPJYglbhiPKpkTYvcr0CTYM+PLYtcFsTakOVd/1L+yGPw3EFD4cdOzHKLn1KkUQIY yGDN6ka2RM2MosnBmTEUrnn52oyz6GTXiWVeDgW8u+pqnjkKLutPo8Hi6xKklP194AQq LFZQ== 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; bh=eSrV5dBwkmZsMu4Ka82lD86iRkWsEW2KmhC9kjHylA0=; b=xlurdpAIhFvcmlizoCo5F1YukRbs55B0ytTJT7zd/dWp/ejffIl9ygDBt92suVN0Ar C5ddSLXYqd2GcpbK+p7z/7J29mhQeHz7eZK+fLVzq1F/N0cVtRO6Yau9KWN/zoBXSpCy idKc2TqHLo4YXmBW49zexnqXQiTu8UmTdj50FOLHxCnnr6b8YYVGp+gcTi8Z4s70TSFg GQPr9zf/bH6+bcZ6WFh1xEFtcQ5amhJr+PuVllT/zneREQtX53DeWPmYjKOUP4GpMpEE jpK1G0DZtBA75uRyPixzIrSzsqFe6u27XSNxme2oJM4Ydl7DY/48tQxo2eN2YIuHr0e0 RKsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=m1YoS9AB; 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=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z72si21576761pgd.34.2019.07.16.21.24.53; Tue, 16 Jul 2019 21:25:10 -0700 (PDT) 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=@oracle.com header.s=corp-2018-07-02 header.b=m1YoS9AB; 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=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726425AbfGQEXL (ORCPT + 99 others); Wed, 17 Jul 2019 00:23:11 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:53734 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725799AbfGQEXL (ORCPT ); Wed, 17 Jul 2019 00:23:11 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x6H4Iv6n044565; Wed, 17 Jul 2019 04:22:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=eSrV5dBwkmZsMu4Ka82lD86iRkWsEW2KmhC9kjHylA0=; b=m1YoS9ABJu0MkSSMKND2HhentO2puo9i3adQ39MoHdTaPa8Uq3HOy93opOyiW7jBaImk TYp3BTPEfKgDntjYPUy38ygBTg8GHvmZE1neY2dMgJDrCWr2QcXFP34Pa8XybrH5M+g5 IhIYCUscLxgVS8FiNytVlitipXERdMOb7qE85iNFCexuAcUEL9guXKb1ePOc98buv4pZ y7Uet2+XlDOFDP3kQmxEYCmDn8toGbhVSnPnIai4gZFe4Jbd1WX9s50FeIlR83CLSFrk yywxhJRRvfMhrsDxyzL8ixsTuupLIlKVW3GnPvho2RbFamr7wEDzyc4pXY/6OgneEymY eA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 2tq78pr1c8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2019 04:22:35 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x6H4IFZI096659; Wed, 17 Jul 2019 04:22:34 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 2tsctwqsjy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2019 04:22:34 +0000 Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x6H4MXWe014705; Wed, 17 Jul 2019 04:22:33 GMT Received: from z2.cn.oracle.com (/10.182.69.87) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 17 Jul 2019 04:22:32 +0000 From: Zhenzhong Duan To: linux-kernel@vger.kernel.org Cc: xen-devel@lists.xenproject.org, boris.ostrovsky@oracle.com, jgross@suse.com, sstabellini@kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, Zhenzhong Duan Subject: [PATCH v8 5/5] x86/xen: Add "nopv" support for HVM guest Date: Tue, 16 Jul 2019 12:26:09 +0800 Message-Id: <1563251169-30740-2-git-send-email-zhenzhong.duan@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1563251169-30740-1-git-send-email-zhenzhong.duan@oracle.com> References: <1563251169-30740-1-git-send-email-zhenzhong.duan@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9320 signatures=668688 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1907170052 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9320 signatures=668688 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1907170052 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org PVH guest needs PV extentions to work, so "nopv" parameter should be ignored for PVH but not for HVM guest. If PVH guest boots up via the Xen-PVH boot entry, xen_pvh is set early, we know it's PVH guest and ignore "nopv" parameter directly. If PVH guest boots up via the normal boot entry same as HVM guest, it's hard to distinguish PVH and HVM guest at that time. In this case, we have to panic early if PVH is detected and nopv is enabled to avoid a worse situation later. Remove static from bool_x86_init_noop/x86_op_int_noop so they could be used globally. Move xen_platform_hvm() after xen_hvm_guest_late_init() to avoid compile error. Signed-off-by: Zhenzhong Duan Reviewed-by: Boris Ostrovsky Cc: Juergen Gross Cc: Stefano Stabellini Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov --- arch/x86/include/asm/x86_init.h | 2 ++ arch/x86/kernel/x86_init.c | 4 ++-- arch/x86/xen/enlighten_hvm.c | 43 +++++++++++++++++++++++++++++++++-------- 3 files changed, 39 insertions(+), 10 deletions(-) diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h index b85a7c5..ac09341 100644 --- a/arch/x86/include/asm/x86_init.h +++ b/arch/x86/include/asm/x86_init.h @@ -301,6 +301,8 @@ struct x86_apic_ops { extern void x86_early_init_platform_quirks(void); extern void x86_init_noop(void); extern void x86_init_uint_noop(unsigned int unused); +extern bool bool_x86_init_noop(void); +extern void x86_op_int_noop(int cpu); extern bool x86_pnpbios_disabled(void); #endif diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c index 50a2b49..1bef687 100644 --- a/arch/x86/kernel/x86_init.c +++ b/arch/x86/kernel/x86_init.c @@ -29,8 +29,8 @@ void x86_init_noop(void) { } void __init x86_init_uint_noop(unsigned int unused) { } static int __init iommu_init_noop(void) { return 0; } static void iommu_shutdown_noop(void) { } -static bool __init bool_x86_init_noop(void) { return false; } -static void x86_op_int_noop(int cpu) { } +bool __init bool_x86_init_noop(void) { return false; } +void x86_op_int_noop(int cpu) { } /* * The platform setup functions are preset with the default functions diff --git a/arch/x86/xen/enlighten_hvm.c b/arch/x86/xen/enlighten_hvm.c index b671983..e138f7d 100644 --- a/arch/x86/xen/enlighten_hvm.c +++ b/arch/x86/xen/enlighten_hvm.c @@ -231,14 +231,6 @@ bool __init xen_hvm_need_lapic(void) return true; } -static uint32_t __init xen_platform_hvm(void) -{ - if (xen_pv_domain()) - return 0; - - return xen_cpuid_base(); -} - static __init void xen_hvm_guest_late_init(void) { #ifdef CONFIG_XEN_PVH @@ -250,6 +242,9 @@ static __init void xen_hvm_guest_late_init(void) /* PVH detected. */ xen_pvh = true; + if (nopv) + panic("\"nopv\" and \"xen_nopv\" parameters are unsupported in PVH guest."); + /* Make sure we don't fall back to (default) ACPI_IRQ_MODEL_PIC. */ if (!nr_ioapics && acpi_irq_model == ACPI_IRQ_MODEL_PIC) acpi_irq_model = ACPI_IRQ_MODEL_PLATFORM; @@ -259,6 +254,37 @@ static __init void xen_hvm_guest_late_init(void) #endif } +static uint32_t __init xen_platform_hvm(void) +{ + uint32_t xen_domain = xen_cpuid_base(); + struct x86_hyper_init *h = &x86_hyper_xen_hvm.init; + + if (xen_pv_domain()) + return 0; + + if (xen_pvh_domain() && nopv) { + /* Guest booting via the Xen-PVH boot entry goes here */ + pr_info("\"nopv\" parameter is ignored in PVH guest\n"); + nopv = false; + } else if (nopv && xen_domain) { + /* + * Guest booting via normal boot entry (like via grub2) goes + * here. + * + * Use interface functions for bare hardware if nopv, + * xen_hvm_guest_late_init is an exception as we need to + * detect PVH and panic there. + */ + h->init_platform = x86_init_noop; + h->x2apic_available = bool_x86_init_noop; + h->init_mem_mapping = x86_init_noop; + h->init_after_bootmem = x86_init_noop; + h->guest_late_init = xen_hvm_guest_late_init; + x86_hyper_xen_hvm.runtime.pin_vcpu = x86_op_int_noop; + } + return xen_domain; +} + struct hypervisor_x86 x86_hyper_xen_hvm __initdata = { .name = "Xen HVM", .detect = xen_platform_hvm, @@ -268,4 +294,5 @@ struct hypervisor_x86 x86_hyper_xen_hvm __initdata = { .init.init_mem_mapping = xen_hvm_init_mem_mapping, .init.guest_late_init = xen_hvm_guest_late_init, .runtime.pin_vcpu = xen_pin_vcpu, + .ignore_nopv = true, }; -- 1.8.3.1