Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4046938imu; Mon, 10 Dec 2018 12:09:41 -0800 (PST) X-Google-Smtp-Source: AFSGD/VlckwCQR6SG0GIrV8elrk6oh/qRQ6cgu6EqTpSOEIHcruzr7D80119Ym2EG1Bgr3XclFPI X-Received: by 2002:a17:902:292b:: with SMTP id g40mr11028370plb.82.1544472581386; Mon, 10 Dec 2018 12:09:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544472581; cv=none; d=google.com; s=arc-20160816; b=0MWjIkGaX6xVApwRjsctp213viy9vkC1hSuibx1extrRfNFc8ruBzAsl0wZQn6an/I 2l973kaeb+Fy/JVOaP5xcfGn4ws4Pv3zGgDUiGmQrQSpLA8jo4yRBZMDZ+FFnNj2+srv rtpaOg0N2NGPD7Lpygx0G/6ywj+/x8P7l3fUMrn15yzimuFoRbN7AHDYLob0ZwPNV72m D3ITJfoPZYZeuwXw2XF4NQzA5omk6XMEZuL0+nTSJX/gRTfTFkydfvkYXjaA9i3Byd7p FmftD9a2Lqj9oaZeBPcEzUQg0S3ecvBOJeCGG7mVLyic8zc864LnsqTBxo0x2rWQeFOu njQA== 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=r+EJebpnfrk/sWr6hWd1Ab7LVK03r8tKPcKLYy60yB0=; b=CCkIeuWbFC9R+emMhSSV8iaxCNJUdIN3Y06JpIeVumRdD9Zyfdh3O19fq5+z1gla/V F8U2/QgXk6Vr8ofDYx0ngQrThdeJniHA+rFWcFE7+V8aw9UBqc+TfBobJSdMk7NCFDLu ffJLnpEIRIuosKMacpXP+ZfYaZAie5b/BzvbHHdnWP57IrYIa0h/qILOn87BwnGaXipH xWZfmxLAMqXOWoBT+rd3Yn6DG2yK6OXA2mh4b4HXA17ncKLgbYcW3Df7cIXdwbxcH0sZ NRwoxO5F/iTaNY1gY5vrfckrI6wbzBlBlZGFZ5VLs9fQ5yNPVm8+X05HS/09sKQp2iXl nZFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=oBLACdtv; 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 102si3127046plc.277.2018.12.10.12.09.26; Mon, 10 Dec 2018 12:09:41 -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=@oracle.com header.s=corp-2018-07-02 header.b=oBLACdtv; 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 S1729210AbeLJTJQ (ORCPT + 99 others); Mon, 10 Dec 2018 14:09:16 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:58078 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729196AbeLJTJN (ORCPT ); Mon, 10 Dec 2018 14:09:13 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wBAJ8nKW115853; Mon, 10 Dec 2018 19:08:54 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=r+EJebpnfrk/sWr6hWd1Ab7LVK03r8tKPcKLYy60yB0=; b=oBLACdtvYCNiRAd/eeuakcbkSeNj3uEx/yoEksT2LXEEaUzGU9VlB/E15TpuPuz0tLso yEWIp/y48F2JfHLDAlfn99GkkFJwMmJSOQwlbasMgfDHtBRkuLq8m6AqtFwvRsuHjEc4 gdyLYAoMGUKaH58H9FsNDe20q7zbR3WLhpWZlcSgvKZKgVPw1OKt5ZHsw15UK2CVQEJq tTeW8zh8OaYfkVmOrGcEWDiC1oddNKLkigaOFMCiemvT2bV9bqG7nF9KPTHduhoKLofD qTAg2AK+4FQmHhLdzNSM3YC+8xm9ZNarjDoEmwwKby6W00ZHEkbm/I+0rRuR7CNyb72C Bg== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2130.oracle.com with ESMTP id 2p83fe01d8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 10 Dec 2018 19:08:54 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id wBAJ8r1d006397 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 10 Dec 2018 19:08:53 GMT Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id wBAJ8re6018718; Mon, 10 Dec 2018 19:08:53 GMT Received: from marawils-linux.us.oracle.com (/10.141.196.37) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 10 Dec 2018 11:08:52 -0800 From: Maran Wilson To: x86@kernel.org, xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, pbonzini@redhat.com, jgross@suse.com Cc: boris.ostrovsky@oracle.com, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, roger.pau@citrix.com, rkrcmar@redhat.com, maran.wilson@oracle.com Subject: [PATCH v9 4/7] xen/pvh: Move Xen specific PVH VM initialization out of common file Date: Mon, 10 Dec 2018 11:08:45 -0800 Message-Id: <1544468926-737-2-git-send-email-maran.wilson@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1544468734-32763-1-git-send-email-maran.wilson@oracle.com> References: <1544468734-32763-1-git-send-email-maran.wilson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9103 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 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-1812100170 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We need to refactor PVH entry code so that support for other hypervisors like Qemu/KVM can be added more easily. This patch moves the small block of code used for initializing Xen PVH virtual machines into the Xen specific file. This initialization is not going to be needed for Qemu/KVM guests. Moving it out of the common file is going to allow us to compile kernels in the future without CONFIG_XEN that are still capable of being booted as a Qemu/KVM guest via the PVH entry point. Signed-off-by: Maran Wilson Reviewed-by: Konrad Rzeszutek Wilk Reviewed-by: Juergen Gross --- arch/x86/platform/pvh/enlighten.c | 29 ++++++++++++++++++++--------- arch/x86/xen/enlighten_pvh.c | 22 +++++++++++++++++++++- include/xen/xen.h | 3 +++ 3 files changed, 44 insertions(+), 10 deletions(-) diff --git a/arch/x86/platform/pvh/enlighten.c b/arch/x86/platform/pvh/enlighten.c index 491932991202..637bd74ba32d 100644 --- a/arch/x86/platform/pvh/enlighten.c +++ b/arch/x86/platform/pvh/enlighten.c @@ -81,27 +81,38 @@ static void __init init_pvh_bootparams(void) x86_init.acpi.get_root_pointer = pvh_get_root_pointer; } +/* + * If we are trying to boot a Xen PVH guest, it is expected that the kernel + * will have been configured to provide the required override for this routine. + */ +void __init __weak xen_pvh_init(void) +{ + xen_raw_printk("Error: Missing xen PVH initialization\n"); + BUG(); +} + +/* + * When we add support for other hypervisors like Qemu/KVM, this routine can + * selectively invoke the appropriate initialization based on guest type. + */ +static void hypervisor_specific_init(void) +{ + xen_pvh_init(); +} + /* * This routine (and those that it might call) should not use * anything that lives in .bss since that segment will be cleared later. */ void __init xen_prepare_pvh(void) { - u32 msr; - u64 pfn; - if (pvh_start_info.magic != XEN_HVM_START_MAGIC_VALUE) { xen_raw_printk("Error: Unexpected magic value (0x%08x)\n", pvh_start_info.magic); BUG(); } - xen_pvh = 1; - xen_start_flags = pvh_start_info.flags; - - msr = cpuid_ebx(xen_cpuid_base() + 2); - pfn = __pa(hypercall_page); - wrmsr_safe(msr, (u32)pfn, (u32)(pfn >> 32)); + hypervisor_specific_init(); init_pvh_bootparams(); } diff --git a/arch/x86/xen/enlighten_pvh.c b/arch/x86/xen/enlighten_pvh.c index 6be7bc719b38..41a7d6ad74e0 100644 --- a/arch/x86/xen/enlighten_pvh.c +++ b/arch/x86/xen/enlighten_pvh.c @@ -1,5 +1,12 @@ // SPDX-License-Identifier: GPL-2.0 -#include +#include + +#include +#include + +#include +#include +#include /* * PVH variables. @@ -8,3 +15,16 @@ * after startup_{32|64} is invoked, which will clear the .bss segment. */ bool xen_pvh __attribute__((section(".data"))) = 0; + +void __init xen_pvh_init(void) +{ + u32 msr; + u64 pfn; + + xen_pvh = 1; + xen_start_flags = pvh_start_info.flags; + + msr = cpuid_ebx(xen_cpuid_base() + 2); + pfn = __pa(hypercall_page); + wrmsr_safe(msr, (u32)pfn, (u32)(pfn >> 32)); +} diff --git a/include/xen/xen.h b/include/xen/xen.h index d7a2678da77f..0e2156786ad2 100644 --- a/include/xen/xen.h +++ b/include/xen/xen.h @@ -29,6 +29,9 @@ extern bool xen_pvh; extern uint32_t xen_start_flags; +#include +extern struct hvm_start_info pvh_start_info; + #ifdef CONFIG_XEN_DOM0 #include #include -- 2.16.1