From patchwork Fri Jan 31 17:49:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11360323 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 22337159A for ; Fri, 31 Jan 2020 17:50:48 +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 F2A00206F0 for ; Fri, 31 Jan 2020 17:50:47 +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="TxglAh6b" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F2A00206F0 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 1ixaQW-0005v2-Kp; Fri, 31 Jan 2020 17:49:56 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ixaQV-0005ua-Is for xen-devel@lists.xenproject.org; Fri, 31 Jan 2020 17:49:55 +0000 X-Inumbo-ID: 0e60f60e-4452-11ea-ad98-bc764e2007e4 Received: from mail-wr1-x443.google.com (unknown [2a00:1450:4864:20::443]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 0e60f60e-4452-11ea-ad98-bc764e2007e4; Fri, 31 Jan 2020 17:49:41 +0000 (UTC) Received: by mail-wr1-x443.google.com with SMTP id z7so9595729wrl.13 for ; Fri, 31 Jan 2020 09:49:41 -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=cpuxdCZxCl63G/9gtJCixou5RUbbkJaTIj6MRYrokwk=; b=TxglAh6bFIrgJs/vD17L60YOOcjmIcgkebD8f8vhNKLEcjahLQzUElfVnOhPmLDTXK iTCrdFsu9ojznKuhIcFGb6aQyS+CW0cYDADdgx5oC7XfLfv+CmwPPcBufxWBzx1MmYOQ yAShKBdAMdX3Oag19nhxxtR2F7bJp66DxNa+2TvOxSqZswkpR88iilHyGTiKRWgarqv0 U5iQ3yVsYerMSutKmH81Zz8szBs2bQCRrzLah7ra/RDhrspZ32HfCyAb68aMxLC1CxkA f3Z60V9i6rr5M09lxz20dA8Rx9fpfuVqdu6nhx2QXB6fkOpSYNKj5+4kBsCbixUuhsYw OCpA== 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=cpuxdCZxCl63G/9gtJCixou5RUbbkJaTIj6MRYrokwk=; b=o+SZoMz+dX9f3Jj3EJZz8uu/hHheCBjMKYVFY5yumKMdxslinEXhCqkMMZ5ibULf1g vurr9PhV033WiDQ/+DVh/jU4prrbm9UUnOD2n4+CepAuzXBK20ZLbNvbLTnRA9d4NZw5 KackGM75CnduB1+5+NCsOWgfKVUYmUxNN1OzBo0soZy0H9wHnf4+j7aFt14R4/PDbaGD 71DGABuWUxz3lPnK8F8e8MpSjfcOn0PxPdxyqz4SOeb9FNZHGc/n1vm6NNBTVU5HzwZc /GOz5ZHYObFXG/CeLCg49LbnXkyT487A/am8LPy42TYh25djJ7bTMf8mwetZI3ts6yku m+kA== X-Gm-Message-State: APjAAAWe9Vde4GqDWGtHv9j9NI6hM4VjDIZ1A0juORpoBMiXcNO5XGd+ 7WouVAxLGQfvTgZbQko4tt4uxOOclcQ= X-Google-Smtp-Source: APXvYqzqLv/ITSSG8633ZAzMoen7M10g76yIC+L7oZ/pr4pSsebfKcMw43nrvYP26Vnxk2qVoA7crg== X-Received: by 2002:a5d:61d1:: with SMTP id q17mr7373278wrv.156.1580492980199; Fri, 31 Jan 2020 09:49:40 -0800 (PST) Received: from localhost.localdomain (41.142.6.51.dyn.plus.net. [51.6.142.41]) by smtp.gmail.com with ESMTPSA id 133sm4364352wmd.5.2020.01.31.09.49.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jan 2020 09:49:39 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Fri, 31 Jan 2020 17:49:23 +0000 Message-Id: <20200131174930.31045-5-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200131174930.31045-1-liuwe@microsoft.com> References: <20200131174930.31045-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v6 04/11] x86/hypervisor: provide hypervisor_fixup_e820 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 , Andrew Cooper , Paul Durrant , Michael Kelley , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" And implement the hook for Xen guest. Signed-off-by: Wei Liu Reviewed-by: Jan Beulich --- xen/arch/x86/e820.c | 4 ++-- xen/arch/x86/guest/hypervisor.c | 6 ++++++ xen/arch/x86/guest/xen/xen.c | 7 +++++++ xen/include/asm-x86/guest/hypervisor.h | 6 ++++++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/e820.c b/xen/arch/x86/e820.c index 3892c9cfb7..2219c63861 100644 --- a/xen/arch/x86/e820.c +++ b/xen/arch/x86/e820.c @@ -690,8 +690,8 @@ unsigned long __init init_e820(const char *str, struct e820map *raw) machine_specific_memory_setup(raw); - if ( pv_shim ) - pv_shim_fixup_e820(&e820); + if ( cpu_has_hypervisor ) + hypervisor_e820_fixup(&e820); printk("%s RAM map:\n", str); print_e820_memory_map(e820.map, e820.nr_map); diff --git a/xen/arch/x86/guest/hypervisor.c b/xen/arch/x86/guest/hypervisor.c index e72c92ffdf..5fd433c8d4 100644 --- a/xen/arch/x86/guest/hypervisor.c +++ b/xen/arch/x86/guest/hypervisor.c @@ -66,6 +66,12 @@ void hypervisor_resume(void) ops->resume(); } +void __init hypervisor_e820_fixup(struct e820map *e820) +{ + if ( ops && ops->e820_fixup ) + ops->e820_fixup(e820); +} + /* * Local variables: * mode: C diff --git a/xen/arch/x86/guest/xen/xen.c b/xen/arch/x86/guest/xen/xen.c index d50f86bae7..45e54dfbba 100644 --- a/xen/arch/x86/guest/xen/xen.c +++ b/xen/arch/x86/guest/xen/xen.c @@ -316,11 +316,18 @@ static void resume(void) pv_console_init(); } +static void __init e820_fixup(struct e820map *e820) +{ + if ( pv_shim ) + pv_shim_fixup_e820(e820); +} + static const struct hypervisor_ops ops = { .name = "Xen", .setup = setup, .ap_setup = ap_setup, .resume = resume, + .e820_fixup = e820_fixup, }; const struct hypervisor_ops *__init xg_probe(void) diff --git a/xen/include/asm-x86/guest/hypervisor.h b/xen/include/asm-x86/guest/hypervisor.h index b503854c5b..b66cb28333 100644 --- a/xen/include/asm-x86/guest/hypervisor.h +++ b/xen/include/asm-x86/guest/hypervisor.h @@ -19,6 +19,8 @@ #ifndef __X86_HYPERVISOR_H__ #define __X86_HYPERVISOR_H__ +#include + struct hypervisor_ops { /* Name of the hypervisor */ const char *name; @@ -28,6 +30,8 @@ struct hypervisor_ops { int (*ap_setup)(void); /* Resume from suspension */ void (*resume)(void); + /* Fix up e820 map */ + void (*e820_fixup)(struct e820map *e820); }; #ifdef CONFIG_GUEST @@ -36,6 +40,7 @@ const char *hypervisor_probe(void); void hypervisor_setup(void); int hypervisor_ap_setup(void); void hypervisor_resume(void); +void hypervisor_e820_fixup(struct e820map *e820); #else @@ -46,6 +51,7 @@ static inline const char *hypervisor_probe(void) { return NULL; } static inline void hypervisor_setup(void) { ASSERT_UNREACHABLE(); } static inline int hypervisor_ap_setup(void) { ASSERT_UNREACHABLE(); return 0; } static inline void hypervisor_resume(void) { ASSERT_UNREACHABLE(); } +static inline void hypervisor_e820_fixup(struct e820map *e820) { ASSERT_UNREACHABLE(); } #endif /* CONFIG_GUEST */