From patchwork Thu Feb 18 23:16:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Kelley X-Patchwork-Id: 385075 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-23.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING, MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A273DC433E6 for ; Thu, 18 Feb 2021 23:18:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6BA7B64E92 for ; Thu, 18 Feb 2021 23:18:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229535AbhBRXSb (ORCPT ); Thu, 18 Feb 2021 18:18:31 -0500 Received: from mail-bn8nam12on2094.outbound.protection.outlook.com ([40.107.237.94]:21217 "EHLO NAM12-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229763AbhBRXSZ (ORCPT ); Thu, 18 Feb 2021 18:18:25 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h9U5PQ1mHxX5uCQLcRlqEkKXVn+j17CLv7/BHRBZLQOIIIT+u2KzPwN6p7rpp4zlAEdI1xkAof255iCEvM1xzGLdGSCZwSscwB4e9fsqx1OsQsnC3G7KXONbsH1hfuS3gVdgVnCQPA7kVfSQb0Z/qcGGP5pbinmOLqfsiX8KM/klLng3+xaFGE+Cd6ylc3CmIxgR97D5PXu6yn8esn3LSKXS/wcFltBsb6wK1+FQ1iOtf43QJbbvB8VuDMCyzT21POKiOQjawAs+HK8HHcr0/4K2nPbrpyDDUCRtTihBCVlcZs/+ef9JBrhkFxoClLvX3Ea0gkQ/1iFr8ERvOseKWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zHRIObbLnIC7Pg5rsxScQMuf2PF3T8GVylMsrGgifkc=; b=REBj+U7S/56izaXI1m/91ARKTsntTsUWcEjBC68I6+Og7oxduG9MBcWFhJoffL+wyaqvtHNYFPXpW0MzH/IIZvSsWFIITG+CUPUMrdXjvr2T+NDSB8aY0AMIy6tTn4C8iN5/cT2TQEklXD9v6NG8q7yO/OrJiRBLb4alWHMWUAZaDVhiGmNcrfld192pKT0cmzpuI+sRl7FdEjynDwUCNEMVTQ3pH+sJJdhJLZxPEVQXrDXP5oQaGBYn3GPw4PeYgMN5g7cPrlN6s90hdP+qGj+aDGTuZZqHUmEJKEXlukYpgddAqhtkLmYEf65rgrZjU6IHMEkNNZGD9ZEWV0cc+w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zHRIObbLnIC7Pg5rsxScQMuf2PF3T8GVylMsrGgifkc=; b=G/zGAWJkXagCC32lDiSp7ipJgbV0BTk89SZSNlwQxls+foRYKwDO2mCOLrNaNGoTGHYo+/Z/6BzHQfLaWrB1gFltbr8EeCUSAvWf4NtRtS0I2TjKLyyD+uQ19nKjTM7O0L0LREC4eDZR1v0w5TB8RYPOEawOI7O3UZp+hGylFTs= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none; kernel.org; dmarc=none action=none header.from=microsoft.com; Received: from (2603:10b6:5:22d::11) by DM5PR2101MB0983.namprd21.prod.outlook.com (2603:10b6:4:a8::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.1; Thu, 18 Feb 2021 23:17:28 +0000 Received: from DM6PR21MB1514.namprd21.prod.outlook.com ([fe80::1c32:e52a:6a36:3ff]) by DM6PR21MB1514.namprd21.prod.outlook.com ([fe80::1c32:e52a:6a36:3ff%5]) with mapi id 15.20.3890.002; Thu, 18 Feb 2021 23:17:28 +0000 From: Michael Kelley To: will@kernel.org, catalin.marinas@arm.com, mark.rutland@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-efi@vger.kernel.org, arnd@arndb.de, wei.liu@kernel.org, ardb@kernel.org, daniel.lezcano@linaro.org, kys@microsoft.com Cc: mikelley@microsoft.com Subject: [PATCH v8 1/6] arm64: hyperv: Add Hyper-V hypercall and register access utilities Date: Thu, 18 Feb 2021 15:16:29 -0800 Message-Id: <1613690194-102905-2-git-send-email-mikelley@microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1613690194-102905-1-git-send-email-mikelley@microsoft.com> References: <1613690194-102905-1-git-send-email-mikelley@microsoft.com> X-Originating-IP: [131.107.147.144] X-ClientProxiedBy: MWHPR10CA0017.namprd10.prod.outlook.com (2603:10b6:301::27) To DM6PR21MB1514.namprd21.prod.outlook.com (2603:10b6:5:22d::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mhkdev.corp.microsoft.com (131.107.147.144) by MWHPR10CA0017.namprd10.prod.outlook.com (2603:10b6:301::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.27 via Frontend Transport; Thu, 18 Feb 2021 23:17:26 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: c167f813-c26a-440a-3281-08d8d4635bba X-MS-TrafficTypeDiagnostic: DM5PR2101MB0983: X-MS-Exchange-Transport-Forked: True X-LD-Processed: 72f988bf-86f1-41af-91ab-2d7cd011db47,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4125; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AUirR0kwsztLfLFiOmO9SyiDDgG11aDS6UGz1ER2nMPK+7ku8tcXmrTcWhBV64MdwQQuhTa8GmJ24jXfo3CRQ16fm5njS1q2m7jsGxXhp4J0VQO2kFA66a0AM1/FxxlRJLrxKNwpePUWAD2NLJXM6ogVSQk55XXe+18C8OK3+s8TSClQADRT1Esvw2WLaiihTdyu422r25NGT8tLVmWfxXPaefXM7nG0VHmna9l9k9YHteI5YtZMAjo8ffqfAtd0l/Vm10kXgQGzESkPDmC//KFef83Ux3l5I44KScKY+JsXDQQXIJV8Hi7OySKA/KxCFN6AeP9561ZDx/Jc5x8PtDTxZlyBhM3WGQuhDt0wcIT2DsvL9yznJ+K/t2TyHe9h90Gv5meMz6cDJUZqH3AkzQPwbjEns2h2MfCNT+XLbozG32YYVoAr2pT7I6JXR2pKc8X79z8oTeud4nqoVIuCrPgXWpSY8GfIXHUUra7nFbiTRy1PJhgwQORxoooUSUW1Wgl9cBAZNte7x5F/hRzT5rCx7WZ1ZCNNuJjE752A970slyEJ3gaxJ8V+aDK3/oVQZInPB+TadXNY+agT9cnFT9EI8eqyxYAS0Mho00atHhG84Vij0LyHvxk9aoB6iVGuFWZ/HqMKyeI6j+fnze+1OA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR21MB1514.namprd21.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(39860400002)(396003)(346002)(366004)(136003)(966005)(5660300002)(6486002)(921005)(107886003)(8676002)(7416002)(82950400001)(2616005)(4326008)(66476007)(478600001)(2906002)(83380400001)(36756003)(186003)(66556008)(6636002)(66946007)(86362001)(10290500003)(956004)(16526019)(26005)(82960400001)(8936002)(52116002)(7696005)(30864003)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: Dn2w7TWxDoBMThNW7C1LhTj5Qox4ZsGE+BOrYgB7Ju2bLG/H/RkDt1H2vSvqKb6Ic5ha3b7ebiBROWSQNqgHqtY/woYAuFUGoK/a2WcEMmMciEj3RCuS17PnjogtiLKNBYnZ2edjrOXnjvmqzssBTjd4pKeNdFh3C+g56E9eEGAQDd3OMDJ67f2iR+7CsMTwz2Yizzc0DxS75ZXXVXp7IQdWZdRDhpFBL9jJ58T7SlFQ2JbrUhaSVV+Hy/ds27PAXRidCLx1maij5tinRRqndOIwlSP/c4wqjQG3uRJKwa5+tioMDn4YQGMMrEDTWUsnoKITFsg+R6xoEtWFNL0KDra8M9lZa3Of6AVhib2YnMq7RaLzonsKIZkFrZ72TKGqsOphBt/YoTvrkCn1qJOIAJAQ/grUKsYOCa+M9SizO+eHoy/Y+Wsa9bOJhrQFvrP8E2vANzEa2Y0oy5PX7aHlBjY27VJc5R8bhr5WEnzEG+u51rRNUQOx8H0UAOxJIIQbyZyf85hzW3mKNNjgPQWrLIAPP5gqy6Lwo9nv+VSjBTUDM2O8P/QCepuMk959HPbZBeuGpbdKN97CcQB1TgYWIIoJrvH7dQ3G+Oxfi05irOtlZeI3XsR6GkQxIvFVTcPe1iWsAea0vOoHEOj3dbdyNLh4PN5/Zwf/YrwyfLNHxaZAcTykAPVuSljISoRxD5ZWN8AzcxrFNPhEmvAyadUDVabOPjz6KRHq3flaYPDyR0EaB0R3OeLHSgfL91D3IOj+YdqgylIt7cqKU6ZQPMJZxoP7H/zQ8UM6D1bPxRRGLMupmNzoeNcX8ukTYkdHxkdrLS8fCUxkyGe/UEBn9L7zHEwy0GVar7VpiL1vIri8Lo3WGAMjtDzxcRSstUuheyS8OlDr83kdETAphWJPFBWGOHECxtNAPJtjd4dQpBljneljHGGH1N5VY/FoB0uLmKvW3p8Tk30yKsogXW85Rc7FA4jls2dBhOZOiVSFMi3gsVYlIGtS34ynjyMpmIRh7/pLSDTCReYorVUjFzjUBF9raQu3XPMRTC+xHkuT2MstmDi8fkAJM1FSjmMf4FUorHFUOLIgP/qVyGuqDxaDwA7JutP0wQiC0GirFBgfBzvVxKCanT2ufEeBCdJQvOqmjvSiRxs5CWhq31a/Yjqc2jnLySzT30eTRsA0UkgvP1HIidpqp5hL075k6wN3xpQKEmAb6MZZSfQbkAnl5BTFEGAKdMl0mue3zTzwZ+SC1r/+0ihEx83F+oYihLRKJ9+HnZkSZHULTj7GVq1CltLttae5c6IXKml7ktl7sTSRWbZgsm4V4+3REzhSfdizoKfxcwfE X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: c167f813-c26a-440a-3281-08d8d4635bba X-MS-Exchange-CrossTenant-AuthSource: DM6PR21MB1514.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2021 23:17:27.9939 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Pqxwg0Xo65QZQgs9gkO3QYzOV1MVthIAFU3KbGw4RlFmBd5FKCOljub9ftxPafgjpnXTKNBkiK43OIS9MHal1g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0983 Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org hyperv-tlfs.h defines Hyper-V interfaces from the Hyper-V Top Level Functional Spec (TLFS), and #includes the architecture-independent part of hyperv-tlfs.h in include/asm-generic. The published TLFS is distinctly oriented to x86/x64, so the ARM64-specific hyperv-tlfs.h includes information for ARM64 that is not yet formally published. The TLFS is available here: docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/reference/tlfs mshyperv.h defines Linux-specific structures and routines for interacting with Hyper-V on ARM64, and #includes the architecture- independent part of mshyperv.h in include/asm-generic. Use these definitions to provide utility functions to make Hyper-V hypercalls and to get and set Hyper-V provided registers associated with a virtual processor. Signed-off-by: Michael Kelley Reviewed-by: Wei Liu --- MAINTAINERS | 3 + arch/arm64/Kbuild | 1 + arch/arm64/hyperv/Makefile | 2 + arch/arm64/hyperv/hv_core.c | 167 +++++++++++++++++++++++++++++++++++ arch/arm64/include/asm/hyperv-tlfs.h | 69 +++++++++++++++ arch/arm64/include/asm/mshyperv.h | 55 ++++++++++++ 6 files changed, 297 insertions(+) create mode 100644 arch/arm64/hyperv/Makefile create mode 100644 arch/arm64/hyperv/hv_core.c create mode 100644 arch/arm64/include/asm/hyperv-tlfs.h create mode 100644 arch/arm64/include/asm/mshyperv.h diff --git a/MAINTAINERS b/MAINTAINERS index 546aa66..0a22f3a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8235,6 +8235,9 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux.git F: Documentation/ABI/stable/sysfs-bus-vmbus F: Documentation/ABI/testing/debugfs-hyperv F: Documentation/networking/device_drivers/ethernet/microsoft/netvsc.rst +F: arch/arm64/hyperv +F: arch/arm64/include/asm/hyperv-tlfs.h +F: arch/arm64/include/asm/mshyperv.h F: arch/x86/hyperv F: arch/x86/include/asm/hyperv-tlfs.h F: arch/x86/include/asm/mshyperv.h diff --git a/arch/arm64/Kbuild b/arch/arm64/Kbuild index d646582..7a37608 100644 --- a/arch/arm64/Kbuild +++ b/arch/arm64/Kbuild @@ -3,4 +3,5 @@ obj-y += kernel/ mm/ obj-$(CONFIG_NET) += net/ obj-$(CONFIG_KVM) += kvm/ obj-$(CONFIG_XEN) += xen/ +obj-$(subst m,y,$(CONFIG_HYPERV)) += hyperv/ obj-$(CONFIG_CRYPTO) += crypto/ diff --git a/arch/arm64/hyperv/Makefile b/arch/arm64/hyperv/Makefile new file mode 100644 index 0000000..1697d30 --- /dev/null +++ b/arch/arm64/hyperv/Makefile @@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0 +obj-y := hv_core.o diff --git a/arch/arm64/hyperv/hv_core.c b/arch/arm64/hyperv/hv_core.c new file mode 100644 index 0000000..9a37124 --- /dev/null +++ b/arch/arm64/hyperv/hv_core.c @@ -0,0 +1,167 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* + * Low level utility routines for interacting with Hyper-V. + * + * Copyright (C) 2021, Microsoft, Inc. + * + * Author : Michael Kelley + */ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * hv_do_hypercall- Invoke the specified hypercall + */ +u64 hv_do_hypercall(u64 control, void *input, void *output) +{ + u64 input_address; + u64 output_address; + struct arm_smccc_res res; + + input_address = input ? virt_to_phys(input) : 0; + output_address = output ? virt_to_phys(output) : 0; + + arm_smccc_1_1_hvc(HV_FUNC_ID, control, + input_address, output_address, &res); + return res.a0; +} +EXPORT_SYMBOL_GPL(hv_do_hypercall); + +/* + * hv_do_fast_hypercall8 -- Invoke the specified hypercall + * with arguments in registers instead of physical memory. + * Avoids the overhead of virt_to_phys for simple hypercalls. + */ + +u64 hv_do_fast_hypercall8(u16 code, u64 input) +{ + u64 control; + struct arm_smccc_res res; + + control = (u64)code | HV_HYPERCALL_FAST_BIT; + + arm_smccc_1_1_hvc(HV_FUNC_ID, control, input, &res); + return res.a0; +} +EXPORT_SYMBOL_GPL(hv_do_fast_hypercall8); + + +/* + * Set a single VP register to a 64-bit value. + */ +void hv_set_vpreg(u32 msr, u64 value) +{ + struct arm_smccc_res res; + + arm_smccc_1_1_hvc( + HV_FUNC_ID, + HVCALL_SET_VP_REGISTERS | HV_HYPERCALL_FAST_BIT | + HV_HYPERCALL_REP_COMP_1, + HV_PARTITION_ID_SELF, + HV_VP_INDEX_SELF, + msr, + 0, + value, + 0, + &res); + + /* + * Something is fundamentally broken in the hypervisor if + * setting a VP register fails. There's really no way to + * continue as a guest VM, so panic. + */ + BUG_ON((res.a0 & HV_HYPERCALL_RESULT_MASK) != HV_STATUS_SUCCESS); +} +EXPORT_SYMBOL_GPL(hv_set_vpreg); + +/* + * Get the value of a single VP register. One version + * returns just 64 bits and another returns the full 128 bits. + * The two versions are separate to avoid complicating the + * calling sequence for the more frequently used 64 bit version. + */ + +void __hv_get_vpreg_128(u32 msr, + struct hv_get_vp_registers_input *input, + struct hv_get_vp_registers_output *res) +{ + u64 status; + + input->header.partitionid = HV_PARTITION_ID_SELF; + input->header.vpindex = HV_VP_INDEX_SELF; + input->header.inputvtl = 0; + input->element[0].name0 = msr; + input->element[0].name1 = 0; + + + status = hv_do_hypercall( + HVCALL_GET_VP_REGISTERS | HV_HYPERCALL_REP_COMP_1, + input, res); + + /* + * Something is fundamentally broken in the hypervisor if + * getting a VP register fails. There's really no way to + * continue as a guest VM, so panic. + */ + BUG_ON((status & HV_HYPERCALL_RESULT_MASK) != HV_STATUS_SUCCESS); +} + +u64 hv_get_vpreg(u32 msr) +{ + struct hv_get_vp_registers_input *input; + struct hv_get_vp_registers_output *output; + u64 result; + + /* + * Allocate a power of 2 size so alignment to that size is + * guaranteed, since the hypercall input and output areas + * must not cross a page boundary. + */ + input = kzalloc(roundup_pow_of_two(sizeof(input->header) + + sizeof(input->element[0])), GFP_ATOMIC); + output = kmalloc(roundup_pow_of_two(sizeof(*output)), GFP_ATOMIC); + + __hv_get_vpreg_128(msr, input, output); + + result = output->as64.low; + kfree(input); + kfree(output); + return result; +} +EXPORT_SYMBOL_GPL(hv_get_vpreg); + +void hv_get_vpreg_128(u32 msr, struct hv_get_vp_registers_output *res) +{ + struct hv_get_vp_registers_input *input; + struct hv_get_vp_registers_output *output; + + /* + * Allocate a power of 2 size so alignment to that size is + * guaranteed, since the hypercall input and output areas + * must not cross a page boundary. + */ + input = kzalloc(roundup_pow_of_two(sizeof(input->header) + + sizeof(input->element[0])), GFP_ATOMIC); + output = kmalloc(roundup_pow_of_two(sizeof(*output)), GFP_ATOMIC); + + __hv_get_vpreg_128(msr, input, output); + + res->as64.low = output->as64.low; + res->as64.high = output->as64.high; + kfree(input); + kfree(output); +} +EXPORT_SYMBOL_GPL(hv_get_vpreg_128); diff --git a/arch/arm64/include/asm/hyperv-tlfs.h b/arch/arm64/include/asm/hyperv-tlfs.h new file mode 100644 index 0000000..4d964a7 --- /dev/null +++ b/arch/arm64/include/asm/hyperv-tlfs.h @@ -0,0 +1,69 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* + * This file contains definitions from the Hyper-V Hypervisor Top-Level + * Functional Specification (TLFS): + * https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/reference/tlfs + * + * Copyright (C) 2021, Microsoft, Inc. + * + * Author : Michael Kelley + */ + +#ifndef _ASM_HYPERV_TLFS_H +#define _ASM_HYPERV_TLFS_H + +#include + +/* + * All data structures defined in the TLFS that are shared between Hyper-V + * and a guest VM use Little Endian byte ordering. This matches the default + * byte ordering of Linux running on ARM64, so no special handling is required. + */ + +/* + * These Hyper-V registers provide information equivalent to the CPUID + * instruction on x86/x64. + */ +#define HV_REGISTER_HYPERVISOR_VERSION 0x00000100 /*CPUID 0x40000002 */ +#define HV_REGISTER_FEATURES 0x00000200 /*CPUID 0x40000003 */ +#define HV_REGISTER_ENLIGHTENMENTS 0x00000201 /*CPUID 0x40000004 */ + +/* + * Group C Features. See the asm-generic version of hyperv-tlfs.h + * for a description of Feature Groups. + */ + +/* Crash MSRs available */ +#define HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE BIT(8) + +/* STIMER direct mode is available */ +#define HV_STIMER_DIRECT_MODE_AVAILABLE BIT(13) + +/* + * Synthetic register definitions equivalent to MSRs on x86/x64 + */ +#define HV_REGISTER_CRASH_P0 0x00000210 +#define HV_REGISTER_CRASH_P1 0x00000211 +#define HV_REGISTER_CRASH_P2 0x00000212 +#define HV_REGISTER_CRASH_P3 0x00000213 +#define HV_REGISTER_CRASH_P4 0x00000214 +#define HV_REGISTER_CRASH_CTL 0x00000215 + +#define HV_REGISTER_GUEST_OSID 0x00090002 +#define HV_REGISTER_VP_INDEX 0x00090003 +#define HV_REGISTER_TIME_REF_COUNT 0x00090004 +#define HV_REGISTER_REFERENCE_TSC 0x00090017 + +#define HV_REGISTER_SINT0 0x000A0000 +#define HV_REGISTER_SCONTROL 0x000A0010 +#define HV_REGISTER_SIEFP 0x000A0012 +#define HV_REGISTER_SIMP 0x000A0013 +#define HV_REGISTER_EOM 0x000A0014 + +#define HV_REGISTER_STIMER0_CONFIG 0x000B0000 +#define HV_REGISTER_STIMER0_COUNT 0x000B0001 + +#include + +#endif diff --git a/arch/arm64/include/asm/mshyperv.h b/arch/arm64/include/asm/mshyperv.h new file mode 100644 index 0000000..44ee012 --- /dev/null +++ b/arch/arm64/include/asm/mshyperv.h @@ -0,0 +1,55 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* + * Linux-specific definitions for managing interactions with Microsoft's + * Hyper-V hypervisor. The definitions in this file are specific to + * the ARM64 architecture. See include/asm-generic/mshyperv.h for + * definitions are that architecture independent. + * + * Definitions that are specified in the Hyper-V Top Level Functional + * Spec (TLFS) should not go in this file, but should instead go in + * hyperv-tlfs.h. + * + * Copyright (C) 2021, Microsoft, Inc. + * + * Author : Michael Kelley + */ + +#ifndef _ASM_MSHYPERV_H +#define _ASM_MSHYPERV_H + +#include +#include +#include + +/* + * Declare calls to get and set Hyper-V VP register values on ARM64, which + * requires a hypercall. + */ + +extern void hv_set_vpreg(u32 reg, u64 value); +extern u64 hv_get_vpreg(u32 reg); +extern void __hv_get_vpreg_128(u32 reg, struct hv_get_vp_registers_input *input, + struct hv_get_vp_registers_output *result); + +static inline void hv_set_register(unsigned int reg, u64 value) +{ + hv_set_vpreg(reg, value); +} + +static inline u64 hv_get_register(unsigned int reg) +{ + return hv_get_vpreg(reg); +} + +/* SMCCC hypercall parameters */ +#define HV_SMCCC_FUNC_NUMBER 1 +#define HV_FUNC_ID ARM_SMCCC_CALL_VAL( \ + ARM_SMCCC_STD_CALL, \ + ARM_SMCCC_SMC_64, \ + ARM_SMCCC_OWNER_VENDOR_HYP, \ + HV_SMCCC_FUNC_NUMBER) + +#include + +#endif From patchwork Thu Feb 18 23:16:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Kelley X-Patchwork-Id: 384610 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30DF5C4332E for ; Thu, 18 Feb 2021 23:19:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0AD2864EB3 for ; Thu, 18 Feb 2021 23:19:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230131AbhBRXS6 (ORCPT ); Thu, 18 Feb 2021 18:18:58 -0500 Received: from mail-bn8nam12on2126.outbound.protection.outlook.com ([40.107.237.126]:8481 "EHLO NAM12-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230112AbhBRXSy (ORCPT ); Thu, 18 Feb 2021 18:18:54 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Srnvh+J3hqx0CAtCkHAPmK+ZcouR9meo5/GcHT0CireRrA0rcfCt99XgSmzmp75WWAV9Y+bufTMQoUeJ6H+XoJYVdDU6hWWXyvUwE40D+f/30EQVhPUZOWg93H1MLaNB8g5K5Pg8hMYJFP3evWhqjC944JPGiCw/KBfLpOZwDYbGT8+1qImiRMFHAfIL/VRB1NqoSYbPi891BbZqrEoEVV7K4mdKJ0w49XvUjk16llHKoSy75Guko7LXIxpaAuFfk+TZNdPpYiNkyJldw5xJsRswVawGP+DA4R7Ng2ZcYipb5rIXZyoGlqqZB0MwtoMf7GBqXFON9kGry2Mdp5imdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EZw2TotSAHaYPjP3Nulqb1SDr7iLBPpWcJEkswmUl1o=; b=JCmR+E9g67QgsW4onRrYL9ida1bbny3PPnTx9VU+S9IsU620FkcOAAxZPiNwLkoRzv8gDHYqjQjTz4kF6Yvdq31Yda0VzgYWBZNWUADwpM/vGpAUjxWVgxxchDm2iHSXK0mDEYWeH1ILLJXeTNfQPmDLXdvF3EegIGTfOffcGIBDUWDcpHE1vICoR5M3mAHVenyqb4MnuwUqGNIukQ9OQEOXteNVBWogoO37p+YdJvy7/j0HQh2WPky1doURdsjHOWpgFE5YvYc0St57Ul0DxPNr9SKngzAe4Qdnzxt3ZXCRArLjH6RFn8T/Fo/EoraH6o5CJuGJupFbJ1ArQku3Vw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EZw2TotSAHaYPjP3Nulqb1SDr7iLBPpWcJEkswmUl1o=; b=dXEhJ9Jxu+byvmT6qqbwL8qxTHOdA5oXyjZB2N6o/4q853X9FJbg5A5dww39dc2chrsTDMtDgfOpmgADt9dLk7Au3GAUePdOy2m9k7rX+ALBPKSPPVg2TPyPhcV6vWKCzWcLBiwTBUH/ve3hks3jTAKRfIdzwE4MrkEpGprOAB8= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none; kernel.org; dmarc=none action=none header.from=microsoft.com; Received: from (2603:10b6:5:22d::11) by DM5PR2101MB0983.namprd21.prod.outlook.com (2603:10b6:4:a8::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.1; Thu, 18 Feb 2021 23:17:29 +0000 Received: from DM6PR21MB1514.namprd21.prod.outlook.com ([fe80::1c32:e52a:6a36:3ff]) by DM6PR21MB1514.namprd21.prod.outlook.com ([fe80::1c32:e52a:6a36:3ff%5]) with mapi id 15.20.3890.002; Thu, 18 Feb 2021 23:17:29 +0000 From: Michael Kelley To: will@kernel.org, catalin.marinas@arm.com, mark.rutland@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-efi@vger.kernel.org, arnd@arndb.de, wei.liu@kernel.org, ardb@kernel.org, daniel.lezcano@linaro.org, kys@microsoft.com Cc: mikelley@microsoft.com Subject: [PATCH v8 2/6] arm64: hyperv: Add Hyper-V clocksource/clockevent support Date: Thu, 18 Feb 2021 15:16:30 -0800 Message-Id: <1613690194-102905-3-git-send-email-mikelley@microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1613690194-102905-1-git-send-email-mikelley@microsoft.com> References: <1613690194-102905-1-git-send-email-mikelley@microsoft.com> X-Originating-IP: [131.107.147.144] X-ClientProxiedBy: MWHPR10CA0017.namprd10.prod.outlook.com (2603:10b6:301::27) To DM6PR21MB1514.namprd21.prod.outlook.com (2603:10b6:5:22d::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mhkdev.corp.microsoft.com (131.107.147.144) by MWHPR10CA0017.namprd10.prod.outlook.com (2603:10b6:301::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.27 via Frontend Transport; Thu, 18 Feb 2021 23:17:28 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: fd1494f3-859a-47a4-1c91-08d8d4635c7d X-MS-TrafficTypeDiagnostic: DM5PR2101MB0983: X-MS-Exchange-Transport-Forked: True X-LD-Processed: 72f988bf-86f1-41af-91ab-2d7cd011db47,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3044; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wlq/XaF2DyX3qF6wUcxz63yRYVF9DYDnG68ajxajJFrMPuif6SLXVHFE81cULo6AY5tjxAGqmrMwn0LDx6mAWgiQvWgyM/tfUdQFtnFxuY9okmQNRliEIqrq4vHfWhDL+/PllCjZwRkwOtGGZrX7BI/nbqWntdwe8QINXwRGJnfPH6/PpIoDc5Z/ydep9ba6F8dAMCJ7YyUHq2aRjkI0P9M/XkcKzxFZayNWbH+bCgO2u/ELSuoIn/geoewPZZFvpNGbPGwcpMtdXUL++PSFtHuxOA7Upm+O9bq4Kz2wBoby5fC8KEo2AvYbgwkR6X+k/+6Lc6eY0ujYxESzyEMOU78VX26dv7nQ6r14HD0tNujYt5qpq0fxtPXjN3bt6n/TJGmalHYp0EH8N4+c52v6GUdxAP9SmH2maRwUk1xgSN3bIvX3VLe574iT7BuyPfom/8w9NO3PBeincNhb291ULh/R9gUwklvcdlOz438/8biTDWFmmUzZJHZ/BM8hkhlzi9h1XoNEc5LPut6EUKGVQcDm8SgtYkhtcnh5vgKWjago8r27s9+9bI7Zo7NITCIc X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR21MB1514.namprd21.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(39860400002)(396003)(346002)(366004)(136003)(5660300002)(6486002)(921005)(107886003)(8676002)(7416002)(82950400001)(2616005)(4326008)(66476007)(478600001)(2906002)(83380400001)(36756003)(186003)(66556008)(6636002)(66946007)(86362001)(10290500003)(956004)(16526019)(26005)(6666004)(82960400001)(8936002)(52116002)(7696005)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: TeXGJVhxJ3oBbAktI4Y0PZsnh6Vaco1XaWezkezAz38gTISRu06FIKJz8BNiTUBqTnrzeUVRmYgWiYVgCP6k8f6qV+VmtlXJPyvLmN5eYiOR7lmZYf7Fy9qqbh669+f6L5p/jy8MjLEQ44pAiJX+IrxwnyrmHF4lU0tnXBZwIi4cPi64GAtmE0gufAde1p6BYQQhmtzugFQLd6XUuqx0cIV8RK4r95t9XtEkgLEAlgQPIuiC/HpIJtKMfGj/uayF89An+56+J0f9J3rxrbrPRAEmDMCMBx5nCDzEfixU9Eiiz9kKbCj2G3NsGBL4w2+UVufGI6u/OXmTNZLcoO7hhaczf8Zln1P22zqif+DIjhLgOezLDZsV4WiY31bvghhYlDNcAbyfaaOyyDjBAhgRyrsIsLx7MNSFL6m4LDgLF7itVuffsYCpyvEZgf8jlFKYRXrA7NMX5fnu3COrmuoAj4Xw4t2I25GYdq+UjJbIjAR67HlKfDRw9q7fDdAq0REMM/UNDGnldYT48O9rq9EKATMcpx/CBNXPp701oVE3B7odGhxtBKdK4onNdAvKAT5u/o2Z24BEpdTwnJSvQ+9vyufor5sXcbXHHSIWwEHwuvdapu16bwc29WyFabmDwrr3Gk1t6eWUqB3ZY0gvM9QgWrRVf2UtHvzJgcjR/VA07CywUXfKso5cKWmUq/R2SHlKjAU746JucTiHLY5BR7aR5IGliT73Of1um1b86UfBHH1wQIy3+YW29CkY91HLR9z3OteFvUxMB8GwzLFVzxvRu0thcuIgZFHg3lknqwGvkF4+zQBZfuVu+IvSX9OTCWGe9Ice9mEDaFPm9lJEdyUFCVA/JcJXfvKdNrEZPkPW2p69Ge35d2OtDQTgDGWZ9C/RfjCAB+5y2aJW3qqOx4kBSqJUCLONqfS33CF1Nc0ShC+NnuHeJ06OTK+dTr4rXZt0h4jDENqm5xEZZgCywxCgSGOzK3V5bj+rFIV0DvdFtS2oDaspuSapLz8fghE56S7HAVz+DKe2Ctxh79W2xOgOOm2255xNJU6T8/Zx4+eckLTVLcaGu/LOZdJVPsdHCxMUmmywcItjeCWRMAqlciI3HtCBzbNZ/MJw8DXGgMFHF9FbSLqc7OHwTPxTIhVtSlLrwQtarvxf2uo30SpwFNOGWhoqt7FUchiIYMosZRfdYXU01GmIUMR5gEWlVUMsetqX8yUBz7uJ+UhfY5anBI3AqSZPxFHvyIEhgaSG+kit2OGH3Ly61ovdG4ubeFWyZAb4xDTnl6GTB5ISeN/MipsWmMUjqb0XcdExulX76h75CVs2WvTrxDKnbYMN71bnLfN3 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: fd1494f3-859a-47a4-1c91-08d8d4635c7d X-MS-Exchange-CrossTenant-AuthSource: DM6PR21MB1514.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2021 23:17:29.2972 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: lF0EV20IuAUgf38VUb//HGxIphJWxvEoBi6gdn+psilKYucQPGyO2fmUuEs7dSQVa8/afie+8ye74QCJYQdqJQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0983 Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org Add architecture specific definitions and functions needed by the architecture independent Hyper-V clocksource driver. Update the Hyper-V clocksource driver to be initialized on ARM64. Signed-off-by: Michael Kelley Reported-by: kernel test robot Reported-by: kernel test robot --- arch/arm64/include/asm/mshyperv.h | 12 ++++++++++++ drivers/clocksource/hyperv_timer.c | 14 ++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/arch/arm64/include/asm/mshyperv.h b/arch/arm64/include/asm/mshyperv.h index 44ee012..d6ff2ee 100644 --- a/arch/arm64/include/asm/mshyperv.h +++ b/arch/arm64/include/asm/mshyperv.h @@ -21,6 +21,7 @@ #include #include #include +#include /* * Declare calls to get and set Hyper-V VP register values on ARM64, which @@ -42,6 +43,17 @@ static inline u64 hv_get_register(unsigned int reg) return hv_get_vpreg(reg); } +/* Define the interrupt ID used by STIMER0 Direct Mode interrupts. This + * value can't come from ACPI tables because it is needed before the + * Linux ACPI subsystem is initialized. + */ +#define HYPERV_STIMER0_VECTOR 31 + +static inline u64 hv_get_raw_timer(void) +{ + return arch_timer_read_counter(); +} + /* SMCCC hypercall parameters */ #define HV_SMCCC_FUNC_NUMBER 1 #define HV_FUNC_ID ARM_SMCCC_CALL_VAL( \ diff --git a/drivers/clocksource/hyperv_timer.c b/drivers/clocksource/hyperv_timer.c index c553b8c..f8bb5df 100644 --- a/drivers/clocksource/hyperv_timer.c +++ b/drivers/clocksource/hyperv_timer.c @@ -567,3 +567,17 @@ void __init hv_init_clocksource(void) hv_setup_sched_clock(read_hv_sched_clock_msr); } EXPORT_SYMBOL_GPL(hv_init_clocksource); + +/* Initialize everything on ARM64 */ +static int __init hyperv_timer_init(struct acpi_table_header *table) +{ + if (!hv_is_hyperv_initialized()) + return -EINVAL; + + hv_init_clocksource(); + if (hv_stimer_alloc(true)) + return -EINVAL; + + return 0; +} +TIMER_ACPI_DECLARE(hyperv, ACPI_SIG_GTDT, hyperv_timer_init); From patchwork Thu Feb 18 23:16:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Kelley X-Patchwork-Id: 384611 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BFD9BC433DB for ; Thu, 18 Feb 2021 23:19:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8D78864EB9 for ; Thu, 18 Feb 2021 23:19:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230101AbhBRXSv (ORCPT ); Thu, 18 Feb 2021 18:18:51 -0500 Received: from mail-bn8nam12on2100.outbound.protection.outlook.com ([40.107.237.100]:10081 "EHLO NAM12-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230090AbhBRXSg (ORCPT ); Thu, 18 Feb 2021 18:18:36 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QK2qlUFPFlhvGRXY09sImmr1zM/iDtO2ZP3vu/DL9F5zk1C4415AqN+erktdVJfuIlbHqjmHGVXF16eS7AaRaAWbrBQ0Xi2XTiYE3s7wrMhgzGIkwAsqJPhoy2k+yC70ujHYf2rFeKW21NFa0rBwNhnpmR7nlYVlbuRJHgN2Deuv5rzrj8wXadJI2nE10B33qGqnD5ip1k6+gC+cPejBwbUbcLE+StYOzXi1pjEW+3/7hTNcgL29h67wRaW4FNVddqlClgTByb7RLvIUOunG076bNzHXJetlcNgOT1BI+N1LTjQUDovE45upSGKeidOh9jtGTQu28YS8twLj74Yeyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8mDWX2st2n1BwqBfjph5HUVeeeH9pNWSle/SPI0wSLA=; b=R3oHzVc6X/FDZDuKfKY0qlb8ISGeJN7VattTmgDUJKXccXQoIAaY+nmLUGRwzspVrjQSRTXRJ3A6a4JfE6F/6YOlCC6x3YLFttM81RI3Fw2zx9V3pLXJqvi8xYcxLUNNXcCSL7CGQJLnlNIVd1y5jnF8tHLpgggTprdg+sae+NQbn2qsmvp4vniLsF3Kak3MIWfZFobaZr/UpehCOnA8L85gAQB3WHBcRQUy54NPjVd7uxbVY8elxiGCNIYCv3O4VG6CEiRtYePRqFEZDFCssKXCb5oBZSTO5d+El6BN/r3DVkHOtTAfIPj1n1Tdthlpar6VC5jTWdK71iV+VG6ZMg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8mDWX2st2n1BwqBfjph5HUVeeeH9pNWSle/SPI0wSLA=; b=apTWzLmECsHTEGAmC7IrymeYdo2djFm1AOt5gF8gDK2qR5ecBCg+aZWeNbhaLcswkcENiULByZ3dB/KZfX0cKDt696h1SNTMbVqD6BK6lT7/J/Vkt0uQbCxIDORxVv9QuGYGLaqy49Ii4CiUAfTiAzmVyXDajdpbNk/qK9TPeVU= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none; kernel.org; dmarc=none action=none header.from=microsoft.com; Received: from (2603:10b6:5:22d::11) by DM5PR2101MB0983.namprd21.prod.outlook.com (2603:10b6:4:a8::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.1; Thu, 18 Feb 2021 23:17:30 +0000 Received: from DM6PR21MB1514.namprd21.prod.outlook.com ([fe80::1c32:e52a:6a36:3ff]) by DM6PR21MB1514.namprd21.prod.outlook.com ([fe80::1c32:e52a:6a36:3ff%5]) with mapi id 15.20.3890.002; Thu, 18 Feb 2021 23:17:30 +0000 From: Michael Kelley To: will@kernel.org, catalin.marinas@arm.com, mark.rutland@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-efi@vger.kernel.org, arnd@arndb.de, wei.liu@kernel.org, ardb@kernel.org, daniel.lezcano@linaro.org, kys@microsoft.com Cc: mikelley@microsoft.com Subject: [PATCH v8 3/6] arm64: hyperv: Add kexec and panic handlers Date: Thu, 18 Feb 2021 15:16:31 -0800 Message-Id: <1613690194-102905-4-git-send-email-mikelley@microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1613690194-102905-1-git-send-email-mikelley@microsoft.com> References: <1613690194-102905-1-git-send-email-mikelley@microsoft.com> X-Originating-IP: [131.107.147.144] X-ClientProxiedBy: MWHPR10CA0017.namprd10.prod.outlook.com (2603:10b6:301::27) To DM6PR21MB1514.namprd21.prod.outlook.com (2603:10b6:5:22d::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mhkdev.corp.microsoft.com (131.107.147.144) by MWHPR10CA0017.namprd10.prod.outlook.com (2603:10b6:301::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.27 via Frontend Transport; Thu, 18 Feb 2021 23:17:29 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 51009632-5301-4708-0bd8-08d8d4635d75 X-MS-TrafficTypeDiagnostic: DM5PR2101MB0983: X-MS-Exchange-Transport-Forked: True X-LD-Processed: 72f988bf-86f1-41af-91ab-2d7cd011db47,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GkKDsK76qk3EbhsdKtaKMTNQmyK9zgZ0HDWEKY1i5CruJcAU7hxAfRSUcZyLPn4M4bTGm+4eFO44Em2iqERqeEhi7ySd38S4CyI+3tFgE6eHFl5hyl8gXkPNMzytb3PXLKWFyjBX9NtoLD6gNV49Firm3o/vccgcpmSIYgvZ0eqWTPpOyi2782CM2n1cpsYUDXcJIg0LH+SsrwkraKCITqlvfHxRHHQDmAfjmSoakyxJ2vYzS9qe25YJGHcaLOcsPndbzpxKzoBLDO9w5oKr2xgWnQ0EoBRDYROCOE70fK1lElh1IZZQ2m8covojWTyJFyFhvuFtu/OfwqPcMbvgY1SeMc+OrAcTFJvsrcwsrhQWaDjdWyE2i+VCvBZwUVjgCzkHaIKcFzcEcUpELYxS1eolfL0sF8ZXAzjFJ1ARuwwDdKohTNxnZqR/PRKKVEMzZmAmPRCiBNGBaU8MHVIpY2ZV439EDHSzduDTQOiDPsKZmj7VRVLY5NhDS+/VL7n1DSMaHQem9pfRGPmy/ZxXur5JdY9of7tCxv39jqTiVmftyv5vNWUX1N1V//uI9nw4 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR21MB1514.namprd21.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(39860400002)(396003)(346002)(366004)(136003)(5660300002)(6486002)(921005)(107886003)(8676002)(7416002)(82950400001)(2616005)(4326008)(66476007)(478600001)(2906002)(83380400001)(36756003)(186003)(66556008)(6636002)(66946007)(86362001)(10290500003)(956004)(16526019)(26005)(6666004)(82960400001)(8936002)(52116002)(7696005)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: dca1jFIbSo5W+6ikSaaEjwmkySPAUOYliPyb+tf73J400QE8khpMKk0yjbJIHTd/5XbtrC6QPN89WveptPha772Vh9fREzw+hKKJw++Zvsu8E1MKljsP8UZYjROYx7LutxOzWDfGE3S2DcEcgpsOBsqzqp2rWKcT6QMvqNesO+ED8uTnU+Qg2FGwEp6wyjgFJXjv+8WVHnJtbpqAME+TzVulg1IYPakUs4JX6pt8elZl4LSXDoueE0m9nuZgcrYAf1L6GPpOOrP0TlNzOuFFvaMyONsx0pgJYnJ20dmo6prCOI5/xDEh5RQdXvKQMTLRpBucr2pmRDV6OTynlRXEivynMiFMQB2wyJxQr5DH36+WEV/sLJ+H95GqoomkzZter4k1Hw+KEYwoqO6ZXhWe+NqHmP81BdTJ3MjSOnqSETEX/w0JpowONmM/5RKYpGVPhGGJbv3tf98TUF1ZRSzXHErT+9CUgsi0m8xS4TUEBFDOIVE4d59JRqUkgHXLVfMXUXkfSuXGIeFUGstYol1wILG+eyi5IELNnveWuvmUMmtR1gFCVIIxOJm+Axfh/xhcu4z/oEK4Q9PNi5HPmzrV+cbRkr/Qruq1tGXvluvzJyEh6a4TEaUnIFH9UjJJZUxcQ/LFb1HYDdICR2JmAvy+AfsnojVdzdiiEOYuMpdNjRSyowyD56iar4o/e9W96kxEItuboajmzKVAcMIZlAmrB2JbXD0Twf7Nvn0p7lBaRB02AFMSJs7Iin15Bx+HgmgJpxmPEIahQ9aKwIALvZzhGIHFwY+MYJ6GGCE1gRY4QG09H/aLtPz6xDSB2BHmToQ+iOvXbnxocwX8bHkGVyB0eVzoUqBBu2WPPDsrkBHxmXghboz4U4gOkxaLJZUa6nbY4VMkdBe57JNHnFzFr7ybpAmwxtP9tkzlhloZmFODv02FJVaES7PGH03SxF2KBULMTyvBNXexaUsLgkbf/vlGdudvIqfI3oRLJnxZAHPEGQlAZMU8EtFu8+2EVYqi+n9vI55JaZVFNU8uRyWCNSToU5gxs399fxkVLmojxOf03QBWrjXc5MPlAw+F5ZNMOBZf3lBfuwEoZ8Mw65x9LA968UUHesjIOgFIuW/SoB+Jy3fO1IL6KeidSRtmix9iWk9gVHA+WDe3KM/qwsJ0pcSKVlwwhy0C9WObalzXhGd9ZZPuH3K+rgGElACNwT2pN5wnvVOsMd6Wqc+mKp0DsVlymTibFVJSKIAeGgjlwsTR8dICaHFIp6FlW+LdsugunfEeOLrTR6rxSsAtCnPcpI+FdO6CqAh1OxhdLkQR4KBPmbtatXj2BHTFcg9ef+AEzA1B X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 51009632-5301-4708-0bd8-08d8d4635d75 X-MS-Exchange-CrossTenant-AuthSource: DM6PR21MB1514.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2021 23:17:30.8932 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: rNRBM8ltN6CFlKqg0apCwwHmHR7/CNJx5+/vwC3sVBntiQH2egdlue8Hc7/HwzRGm1OUoPopCpVW2nWhvYB8Mw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0983 Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org Add function to inform Hyper-V about a guest panic. Also add functions to set up and remove kexec and panic handlers, which are currently unused on ARM64 but are called from architecture independent code in the VMbus driver. This code is built only when CONFIG_HYPERV is enabled. Signed-off-by: Michael Kelley --- arch/arm64/hyperv/Makefile | 2 +- arch/arm64/hyperv/hv_core.c | 53 +++++++++++++++++++++++++++++++++++++++++++ arch/arm64/hyperv/mshyperv.c | 54 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 arch/arm64/hyperv/mshyperv.c diff --git a/arch/arm64/hyperv/Makefile b/arch/arm64/hyperv/Makefile index 1697d30..87c31c0 100644 --- a/arch/arm64/hyperv/Makefile +++ b/arch/arm64/hyperv/Makefile @@ -1,2 +1,2 @@ # SPDX-License-Identifier: GPL-2.0 -obj-y := hv_core.o +obj-y := hv_core.o mshyperv.o diff --git a/arch/arm64/hyperv/hv_core.c b/arch/arm64/hyperv/hv_core.c index 9a37124..d4e3808 100644 --- a/arch/arm64/hyperv/hv_core.c +++ b/arch/arm64/hyperv/hv_core.c @@ -165,3 +165,56 @@ void hv_get_vpreg_128(u32 msr, struct hv_get_vp_registers_output *res) kfree(output); } EXPORT_SYMBOL_GPL(hv_get_vpreg_128); + +/* + * hyperv_report_panic - report a panic to Hyper-V. This function uses + * the older version of the Hyper-V interface that admittedly doesn't + * pass enough information to be useful beyond just recording the + * occurrence of a panic. The parallel hv_kmsg_dump() uses the + * new interface that allows reporting 4 Kbytes of data, which is much + * more useful. Hyper-V on ARM64 always supports the newer interface, but + * we retain support for the older version because the sysadmin is allowed + * to disable the newer version via sysctl in case of information security + * concerns about the more verbose version. + */ +void hyperv_report_panic(struct pt_regs *regs, long err, bool in_die) +{ + static bool panic_reported; + u64 guest_id; + + /* Don't report a panic to Hyper-V if we're not going to panic */ + if (in_die && !panic_on_oops) + return; + + /* + * We prefer to report panic on 'die' chain as we have proper + * registers to report, but if we miss it (e.g. on BUG()) we need + * to report it on 'panic'. + * + * Calling code in the 'die' and 'panic' paths ensures that only + * one CPU is running this code, so no atomicity is needed. + */ + if (panic_reported) + return; + panic_reported = true; + + guest_id = hv_get_vpreg(HV_REGISTER_GUEST_OSID); + + /* + * Hyper-V provides the ability to store only 5 values. + * Pick the passed in error value, the guest_id, and the PC. + * The first two general registers are added arbitrarily. + */ + hv_set_vpreg(HV_REGISTER_CRASH_P0, err); + hv_set_vpreg(HV_REGISTER_CRASH_P1, guest_id); + hv_set_vpreg(HV_REGISTER_CRASH_P2, regs->pc); + hv_set_vpreg(HV_REGISTER_CRASH_P3, regs->regs[0]); + hv_set_vpreg(HV_REGISTER_CRASH_P4, regs->regs[1]); + + /* + * Let Hyper-V know there is crash data available + */ + hv_set_vpreg(HV_REGISTER_CRASH_CTL, HV_CRASH_CTL_CRASH_NOTIFY); +} +EXPORT_SYMBOL_GPL(hyperv_report_panic); + diff --git a/arch/arm64/hyperv/mshyperv.c b/arch/arm64/hyperv/mshyperv.c new file mode 100644 index 0000000..d202b4c --- /dev/null +++ b/arch/arm64/hyperv/mshyperv.c @@ -0,0 +1,54 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* + * Core routines for interacting with Microsoft's Hyper-V hypervisor. + * Includes hypervisor initialization, and handling of crashes and + * kexecs through a set of static "handler" variables set by the + * architecture independent VMbus driver. + * + * Copyright (C) 2021, Microsoft, Inc. + * + * Author : Michael Kelley + */ + +#include +#include +#include + +/* + * The VMbus handler functions are no-ops on ARM64 because + * VMbus interrupts are handled as percpu IRQs. + */ +void hv_setup_vmbus_handler(void (*handler)(void)) +{ +} +EXPORT_SYMBOL_GPL(hv_setup_vmbus_handler); + +void hv_remove_vmbus_handler(void) +{ +} +EXPORT_SYMBOL_GPL(hv_remove_vmbus_handler); + +/* + * The kexec and crash handler functions are + * currently no-ops on ARM64. + */ +void hv_setup_kexec_handler(void (*handler)(void)) +{ +} +EXPORT_SYMBOL_GPL(hv_setup_kexec_handler); + +void hv_remove_kexec_handler(void) +{ +} +EXPORT_SYMBOL_GPL(hv_remove_kexec_handler); + +void hv_setup_crash_handler(void (*handler)(struct pt_regs *regs)) +{ +} +EXPORT_SYMBOL_GPL(hv_setup_crash_handler); + +void hv_remove_crash_handler(void) +{ +} +EXPORT_SYMBOL_GPL(hv_remove_crash_handler); From patchwork Thu Feb 18 23:16:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Kelley X-Patchwork-Id: 385074 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 128E8C4332B for ; Thu, 18 Feb 2021 23:19:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D978A64ECE for ; Thu, 18 Feb 2021 23:19:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230124AbhBRXSx (ORCPT ); Thu, 18 Feb 2021 18:18:53 -0500 Received: from mail-bn8nam12on2094.outbound.protection.outlook.com ([40.107.237.94]:21217 "EHLO NAM12-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229763AbhBRXSt (ORCPT ); Thu, 18 Feb 2021 18:18:49 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e7ZOVX4xQQm5ACfE0KcglE3AR4sclsRHirGCmZzHPocibDseDsQ7xRbZBfmR3t9NadtVR2lrixk897E6UMEUuq/6biI4QcdJlGw8ny3DePAGHeNPmFIY6X8TDz+hXUjChaFUM8DEXnZCZXgsb0fZKVIR2ObvJTaXP/wecYuVY6+QUr3NdYYdeMvQdZJzmxK7NvPE+piZSerhH5FR4SSz70SPZYRSON9fuCp/AFwT3YRyNJaZ3J+WeooGpPHu7DVCvREsN2vsUWkzh67twPzgm4dsU4Gts27JH60ETYrjXu5yZh9wA3oZyQCJexl9h05GL+0xPooiQz0A8vpmA0lPsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rDo+ZDvoLmIi/KDXSyw1p9toB337nlXDJdQCCtPfvy8=; b=fhL/5NMk/TNJ2tfuA64sjghAarGwC2i+sNi7BSnon97s+gxMoqsWZzaKp7sqkRJeV9aI9Dl7EI8IhJRlNFGw/ddiffnpklVSJvApKKrr01FkY6bJiGxSUKzVIoEXhhAHuqdxgbuhUDqnT7nAc59N2H2xq3kQs1IGvY2RM7Ycf3X2snQYTUzfP+XUuWFHHOH68iGV9XZPPFG8FnJJzEUZGbXPu5f7deCessRSNjWgx+uBh++6oc7/7Q9qefkQmYnF1UCxC+LOdiBE7gBd7yJ19uuQ7zO5ysJ/NKohAVUz4N8jTuMmLkdjla0lG6CjuE4kD7H2BN3DRZrl8j8u8vaVcw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rDo+ZDvoLmIi/KDXSyw1p9toB337nlXDJdQCCtPfvy8=; b=NpRc3iFLPLtm+6unMP1idYXgmkYBC40ImNDPg8QejC7dGxNU+97JvZRzy7VFiOW/kaJ0PjhRyR1lsxpza0EDlFNHm/z7x9mdrMldrdsfHYQqQ0iOkyJ1VoN+qGFlL+UcLaLhQPBNKKtObEy+HE4RjR3AYDGUfXb1xWCUJb41qM0= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none; kernel.org; dmarc=none action=none header.from=microsoft.com; Received: from (2603:10b6:5:22d::11) by DM5PR2101MB0983.namprd21.prod.outlook.com (2603:10b6:4:a8::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.1; Thu, 18 Feb 2021 23:17:32 +0000 Received: from DM6PR21MB1514.namprd21.prod.outlook.com ([fe80::1c32:e52a:6a36:3ff]) by DM6PR21MB1514.namprd21.prod.outlook.com ([fe80::1c32:e52a:6a36:3ff%5]) with mapi id 15.20.3890.002; Thu, 18 Feb 2021 23:17:32 +0000 From: Michael Kelley To: will@kernel.org, catalin.marinas@arm.com, mark.rutland@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-efi@vger.kernel.org, arnd@arndb.de, wei.liu@kernel.org, ardb@kernel.org, daniel.lezcano@linaro.org, kys@microsoft.com Cc: mikelley@microsoft.com Subject: [PATCH v8 4/6] arm64: hyperv: Initialize hypervisor on boot Date: Thu, 18 Feb 2021 15:16:32 -0800 Message-Id: <1613690194-102905-5-git-send-email-mikelley@microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1613690194-102905-1-git-send-email-mikelley@microsoft.com> References: <1613690194-102905-1-git-send-email-mikelley@microsoft.com> X-Originating-IP: [131.107.147.144] X-ClientProxiedBy: MWHPR10CA0017.namprd10.prod.outlook.com (2603:10b6:301::27) To DM6PR21MB1514.namprd21.prod.outlook.com (2603:10b6:5:22d::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mhkdev.corp.microsoft.com (131.107.147.144) by MWHPR10CA0017.namprd10.prod.outlook.com (2603:10b6:301::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.27 via Frontend Transport; Thu, 18 Feb 2021 23:17:31 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: da76dd83-3e32-49f8-4af7-08d8d4635e4e X-MS-TrafficTypeDiagnostic: DM5PR2101MB0983: X-MS-Exchange-Transport-Forked: True X-LD-Processed: 72f988bf-86f1-41af-91ab-2d7cd011db47,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2331; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EtogyOUr91yQgx2+Ug3PncNKFyv+CeqApdcRUs3Kip5bwEomrG9f4tgn1iUnLP29HHY4hAboN+NZ8lbp52BVp/d2xT3JT7MLCNYfNc2rijerjjRivBnq0jZVdAdsTi2DyLNj+PqgiNR+fjUeudRX3HZmM3nGgMLvManbW4WzdWekIE7/0lfInRbD6PnbOb/bUKY0ZyUTQyvM2VUIObbQQcULX5Kgsm0M9eOySq7KdwwiOXY/ihRQsXNFR+/PIyDIHKq9wRvMvwZDoGtpgTNIjJJI7/VHY3QwNJBMEg17lD1FOww3jm/R+Dczktolmmt5AFAD9TCsLv5VCtqn/Sfq3w1BOgxl39NSw5YSv+8lOMjBqUJGholmYqO3I+fokx9ZA+ohMsMxTxxeBx62ZYNXLP6sAW7Q7v0qnZQC/nMQuhXA8Ot2rE20yFQC7QJGCFZ4LKE8PccYcPq4r8K9PXuwwa6KWh4t6T2MA86sLlR4G745NWfJRp0MTLlAVpATvhUQmvd/7L/vRiezr76PdThdWx+vGU4qntdkNxepzd3fskEzpGVyh9ubYLgNnQApZ/Bu X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR21MB1514.namprd21.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(39860400002)(396003)(346002)(366004)(136003)(5660300002)(6486002)(921005)(107886003)(8676002)(7416002)(82950400001)(2616005)(4326008)(66476007)(478600001)(2906002)(83380400001)(36756003)(186003)(66556008)(6636002)(66946007)(86362001)(10290500003)(956004)(16526019)(26005)(82960400001)(8936002)(52116002)(7696005)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: jbaHnewebbHwf37f3Ak7fyZbkji408Si0zQ3+dX7eqWLl6/krK5IozUVBCIVI4oK+P2yNMC51ycq6XQhQVtJuEQaom+uHPOO//ZF5aZmtXygj44pWWOBrfQ9kBiQW2/WUexHMjWAY1oWsdlnmWlvUk+nED4i4FK9CylqONq1xGzG95hVTeEmhIQtgxBk2YH+jAH+f1cggJa4PGyGSy+2AwA9HqwOpYRtOq/ESoy9Y6oG9oWFV6LkB9JGaRp14SYM4t5QuDAw2v4qbQlZ3fT58xHTu0GoeGzs6y47P7GOPlAhfWfL3/0RS6nGoY5ONLaxlrji6GhTewrwzhJbQahZyyvfhqHXne6h5Idrz7zpKBeI4ultBDdG0UHanU5fYK5BZTVPwmioIhRdny3jE93qa7cBBNBwQLhYGEF9Pr0OARLp56CAaWqvoQ7NSfWzezpzf76/yQ+Ue8OZoHg/qEEYWF6rEIV3Bworca4dy1Bs8q0ySTawHJ4qy2RHro2xbp/ukS9OZz7aEU1HKy4gkGKaXyKDd6pWDJiDxz/TE1hiOQEthGAgpwarTVE3rPSFwLFSR4emcw2iYCOvIX0UWJuPm+tVpn3sPmDW50ydZnjAfmq2QvkCtqSdlrNYIRV9Tbp1f27rjHXxcj4NTPI8UOvf9pH3qB6rRj0Cnb0dSF1/aQlLMe4OaY9wqLgtRRXNOSoveD+V1PfJ1JMIIvQ+avC7+zhGMNH3BL+K9gFKpewqxVzOxJW1y+hli+rRE+Yd690k/Z7Si3RDHudStNpZvKoI4WiRYD6brR/wV27ad6OH+DkHxwhModyYQiMfulw6WOvv3mxHZox5LBojJ1WDTET7TPa2AE2WNbH/tDsRkzzvkRhzAdyKVTuGg97X2KHzaHdcfgwi4AFRaXP1HMkeoLJ6pdZsQS5AB3uXpoetv3yWQRXJAE2TAFDpXkoyNeyzM50Zeirdfkm5W6fT/fG9DvPHVm/VA5IyZuaiSxOsRfChWNkscVgd61vizlywJ4beIUCyk0uFDUS6h+th9XvV2YZ1EA4qKvbR4VqnZTvmm7pp3bQm7d7upE1SNWXf/j7+z9wZz/OHDdFrf2OLdlEvtl2hNqos7MGrkb0RPrB4dVRb2gRacWRUXIiHO3J2nEQ1oK+0ShvNTszgqm1OJ7b9aZnB4qZrcumHfF4Gq29UQxy2FNgLuxIXAP8b7l1CeJq/E2KRZPbp0glLNmzYl2qVshwBlGCLDQXqDPOW2ZdINpk+WWK8qtjcYvLiJXIYe7ZFE69DdYo78rkPRGCnLphjbIO4z2U3JxFE3ADAp35yG91T2pvz85Bt9xDQyG0wGAIxsJl7 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: da76dd83-3e32-49f8-4af7-08d8d4635e4e X-MS-Exchange-CrossTenant-AuthSource: DM6PR21MB1514.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2021 23:17:32.3100 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: iV11DvYPkNGWk+PWi4dMP3auChQX98c5Rv1EAvKO/xnCH1ogQNLYXeZ3fSZoIrgQjWs7yJdOO145bL0tLSGafg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0983 Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org Add ARM64-specific code to initialize the Hyper-V hypervisor when booting as a guest VM. Provide functions and data structures indicating hypervisor status that are needed by VMbus driver. This code is built only when CONFIG_HYPERV is enabled. Signed-off-by: Michael Kelley --- arch/arm64/hyperv/mshyperv.c | 140 ++++++++++++++++++++++++++++++++++++++ arch/arm64/include/asm/mshyperv.h | 6 ++ arch/arm64/kernel/setup.c | 4 ++ 3 files changed, 150 insertions(+) diff --git a/arch/arm64/hyperv/mshyperv.c b/arch/arm64/hyperv/mshyperv.c index d202b4c..c72bc66 100644 --- a/arch/arm64/hyperv/mshyperv.c +++ b/arch/arm64/hyperv/mshyperv.c @@ -14,6 +14,146 @@ #include #include #include +#include +#include +#include +#include +#include + +static bool hyperv_initialized; + +struct ms_hyperv_info ms_hyperv __ro_after_init; +EXPORT_SYMBOL_GPL(ms_hyperv); + +u32 *hv_vp_index; +EXPORT_SYMBOL_GPL(hv_vp_index); + +u32 hv_max_vp_index; +EXPORT_SYMBOL_GPL(hv_max_vp_index); + +/* + * As hypercall input and output, align to a power of 2 to ensure they + * don't cross a page boundary. Initialize the first element of the + * variable size array in the input to ensure enough space is allocated. + */ +static struct hv_get_vp_registers_input input __initdata __aligned( + roundup_pow_of_two(sizeof(struct hv_get_vp_registers_input) + + sizeof(struct input))) = {.element[0].name0 = 1}; +static struct hv_get_vp_registers_output result __initdata __aligned( + roundup_pow_of_two(sizeof(struct hv_get_vp_registers_output))); + +void __init hyperv_early_init(void) +{ + u32 a, b, c, d; + u64 guest_id; + + /* + * If we're in a VM on Hyper-V, the ACPI hypervisor_id field will + * have the string "MsHyperV". + */ + if (strncmp((char *)&acpi_gbl_FADT.hypervisor_id, "MsHyperV", 8)) + return; + + /* Setup the guest ID */ + guest_id = generate_guest_id(0, LINUX_VERSION_CODE, 0); + hv_set_vpreg(HV_REGISTER_GUEST_OSID, guest_id); + + /* Get the features and hints from Hyper-V */ + __hv_get_vpreg_128(HV_REGISTER_FEATURES, &input, &result); + ms_hyperv.features = result.as32.a; + ms_hyperv.misc_features = result.as32.c; + + __hv_get_vpreg_128(HV_REGISTER_ENLIGHTENMENTS, &input, &result); + ms_hyperv.hints = result.as32.a; + + pr_info("Hyper-V: Features 0x%x, hints 0x%x, misc 0x%x\n", + ms_hyperv.features, ms_hyperv.hints, ms_hyperv.misc_features); + + /* + * If Hyper-V has crash notifications, set crash_kexec_post_notifiers + * so that we will report the panic to Hyper-V before running kdump. + */ + if (ms_hyperv.misc_features & HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE) + crash_kexec_post_notifiers = true; + + /* Get information about the Hyper-V host version */ + __hv_get_vpreg_128(HV_REGISTER_HYPERVISOR_VERSION, &input, &result); + a = result.as32.a; + b = result.as32.b; + c = result.as32.c; + d = result.as32.d; + pr_info("Hyper-V: Host Build %d.%d.%d.%d-%d-%d\n", + b >> 16, b & 0xFFFF, a, d & 0xFFFFFF, c, d >> 24); + + hyperv_initialized = true; +} + +static u64 hypercall_output __initdata; + +static int __init hyperv_init(void) +{ + struct hv_get_vpindex_from_apicid_input *input; + u64 status; + int i; + + /* + * Hypercall inputs must not cross a page boundary, so allocate + * power of 2 size, which will be aligned to that size. + */ + input = kzalloc(roundup_pow_of_two(sizeof(input->header) + + sizeof(input->element[0])), GFP_KERNEL); + if (!input) + return -ENOMEM; + + /* Allocate and initialize percpu VP index array */ + hv_max_vp_index = num_possible_cpus(); + hv_vp_index = kmalloc_array(hv_max_vp_index, sizeof(*hv_vp_index), + GFP_KERNEL); + if (!hv_vp_index) { + kfree(input); + return -ENOMEM; + } + + input->header.partitionid = HV_PARTITION_ID_SELF; + for (i = 0; i < hv_max_vp_index; i++) { + input->element[0].mpidr = cpu_logical_map(i); + status = hv_do_hypercall(HVCALL_VPINDEX_FROM_APICID | + HV_HYPERCALL_REP_COMP_1, input, + &hypercall_output); + if ((status & HV_HYPERCALL_RESULT_MASK) == HV_STATUS_SUCCESS) + hv_vp_index[i] = hypercall_output; + else { + pr_warn("Hyper-V: No VP index for CPU %d MPIDR %llx status %llx\n", + i, cpu_logical_map(i), status); + hv_vp_index[i] = VP_INVAL; + } + } + + kfree(input); + return 0; +} + +early_initcall(hyperv_init); + +/* This routine is called before kexec/kdump. It does required cleanup. */ +void hyperv_cleanup(void) +{ + hv_set_vpreg(HV_REGISTER_GUEST_OSID, 0); + +} +EXPORT_SYMBOL_GPL(hyperv_cleanup); + +bool hv_is_hyperv_initialized(void) +{ + return hyperv_initialized; +} +EXPORT_SYMBOL_GPL(hv_is_hyperv_initialized); + +bool hv_is_hibernation_supported(void) +{ + return false; +} +EXPORT_SYMBOL_GPL(hv_is_hibernation_supported); /* * The VMbus handler functions are no-ops on ARM64 because diff --git a/arch/arm64/include/asm/mshyperv.h b/arch/arm64/include/asm/mshyperv.h index d6ff2ee..55a61a8 100644 --- a/arch/arm64/include/asm/mshyperv.h +++ b/arch/arm64/include/asm/mshyperv.h @@ -23,6 +23,12 @@ #include #include +#if IS_ENABLED(CONFIG_HYPERV) +void __init hyperv_early_init(void); +#else +static inline void hyperv_early_init(void) {}; +#endif + /* * Declare calls to get and set Hyper-V VP register values on ARM64, which * requires a hypercall. diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index c18aacd..1df8285 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -49,6 +49,7 @@ #include #include #include +#include #include static int num_standard_resources; @@ -340,6 +341,9 @@ void __init __no_sanitize_address setup_arch(char **cmdline_p) if (acpi_disabled) unflatten_device_tree(); + /* Do after acpi_boot_table_init() so local FADT is available */ + hyperv_early_init(); + bootmem_init(); kasan_init(); From patchwork Thu Feb 18 23:16:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Kelley X-Patchwork-Id: 385073 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E9E2C433E6 for ; Thu, 18 Feb 2021 23:19:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 48D4B64E92 for ; Thu, 18 Feb 2021 23:19:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229799AbhBRXTj (ORCPT ); Thu, 18 Feb 2021 18:19:39 -0500 Received: from mail-bn8nam12on2100.outbound.protection.outlook.com ([40.107.237.100]:10081 "EHLO NAM12-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230145AbhBRXTI (ORCPT ); Thu, 18 Feb 2021 18:19:08 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e/bh4R3BSJ5Ix/YiBDRxdqn8mRWJR9azvMBl0biQjkZ9vfeRkk+EhIrxUFofFoDlJmLu3h/Q5lHv7A6GvJ4YLh8j9+whp3MZYPYkLieelfLMJVmA3RN2ODNDMy7iofxsf9KGGoD8NrbbYunWoDtpD0/UgkIcNwYH82alYes0b4GaxfqUD5GK0Cb9h4OUO3HRQUoOtDe22e4BhDxsBdavk2bOMuKyO6Q6trWcQRJrngcdS8i770avZzB1IzkCyQv3t4nTKaypx+wpxx++iiDi2IHst/jpAVEOPLK8pN9lC2rrW8QnRYUMwqPW+C/j/9wryE6PtWJBtTkSH2axVwiGyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Mlo2yDKTnZXGpH6Rnfo6Np0t3b6NB4ioh4U9dPBlFn0=; b=il842BbcbXBnelTJvcvn5tcJKmIbtORuv9L6QGa00ifai49DD7gJN5YJ39cuEhospZcyV8OMa7LHqWPt93B1+G0ucYQraJkxahU1pqr4vNV577A5blSwOO7YiWHo1k+N0mYTUkrV1y9ow17Qp61+UlxHzSQYvm2t9lm8vWMWLx6T0y9+G1XLndinnD25vFh644prPhko00f1Qm9ZGSQhQBWWgxpPGiDeeANFl5Vcn4sXH9pwIn1jl2ViPmjHSoyXUXK0a+S0+OuEa5VLnH567Rwu0mODDwquD4BI2EV7FUqO+rkhpEs1KGeMZb6IxHgMqlk5lkgFmCcWKnwSGM83bQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Mlo2yDKTnZXGpH6Rnfo6Np0t3b6NB4ioh4U9dPBlFn0=; b=SxrM/+xZqXm9wgdBViFwKUoWR5j4OyAv+MdsexRv5/U5AYoJo1LiXXX2yx/FEISK7T5vRolcOmr6Fo6NvPubCNpjd3nT9A4kOFixgV7DhAsPsJUy2Ud0N+iP6ybEHyLGPWdcgsLS23RvqGf+kprXcmvDPFwR7Q/dtiNhO6i/T8c= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none; kernel.org; dmarc=none action=none header.from=microsoft.com; Received: from (2603:10b6:5:22d::11) by DM5PR2101MB0983.namprd21.prod.outlook.com (2603:10b6:4:a8::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.1; Thu, 18 Feb 2021 23:17:33 +0000 Received: from DM6PR21MB1514.namprd21.prod.outlook.com ([fe80::1c32:e52a:6a36:3ff]) by DM6PR21MB1514.namprd21.prod.outlook.com ([fe80::1c32:e52a:6a36:3ff%5]) with mapi id 15.20.3890.002; Thu, 18 Feb 2021 23:17:33 +0000 From: Michael Kelley To: will@kernel.org, catalin.marinas@arm.com, mark.rutland@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-efi@vger.kernel.org, arnd@arndb.de, wei.liu@kernel.org, ardb@kernel.org, daniel.lezcano@linaro.org, kys@microsoft.com Cc: mikelley@microsoft.com Subject: [PATCH v8 5/6] arm64: efi: Export screen_info Date: Thu, 18 Feb 2021 15:16:33 -0800 Message-Id: <1613690194-102905-6-git-send-email-mikelley@microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1613690194-102905-1-git-send-email-mikelley@microsoft.com> References: <1613690194-102905-1-git-send-email-mikelley@microsoft.com> X-Originating-IP: [131.107.147.144] X-ClientProxiedBy: MWHPR10CA0017.namprd10.prod.outlook.com (2603:10b6:301::27) To DM6PR21MB1514.namprd21.prod.outlook.com (2603:10b6:5:22d::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mhkdev.corp.microsoft.com (131.107.147.144) by MWHPR10CA0017.namprd10.prod.outlook.com (2603:10b6:301::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.27 via Frontend Transport; Thu, 18 Feb 2021 23:17:32 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: afa23990-412d-4a5f-c6c5-08d8d4635f0e X-MS-TrafficTypeDiagnostic: DM5PR2101MB0983: X-MS-Exchange-Transport-Forked: True X-LD-Processed: 72f988bf-86f1-41af-91ab-2d7cd011db47,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4WHz1LnvCQ+wSnEektaej/LacbzdX1FwG5EqhKlaZe8TV9BRMlWbvc7/XBg+shZ+m6iAkY5c54zFCObM7qfDFiX16avDIYi2dilNpTHhG0sSCEhR4nVE5bYtgQEcropW9JIQIJsodPQGGS4wqhOpux7SQ05zepUeQFJwCkcj/27ra6NVL+J7rx0+cjEiCNVUU6wyLOe+D/Wm7bpcP8lcYQMX8+9eT4lE/vjj+SNdacOx/xO0queX/D3WFx7E/NmvfeEDJ3bqVSK89VYnQ/0U69sQcDp3R0h0NWQRPJV7a3yBzNSqUuG7928IVU5bh1QzMUiU+89qL+pRDWP9Fa0O8YhNuXZ6U7ecM8hzhQ3JDeHMr+JbFvFWVNHyNnygMINLJSuu88mbw/Y2iA8ueyploJcFpFcfPqE+mbyEqyPsr2rxEP8WSUlZtI5oAtR7hEGvcf5lipV/8vBiWoUwAbhg5mJ9J0TpAEoktKYINcrDdiQyS/9HTlrXQiEE5NyyXHRwryy0A14DodGVp6Tm0onoEVQ/5dCsxkEz9rkJ1GngZxgu7Fp9TgiIOY35wCtar2wS X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR21MB1514.namprd21.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(39860400002)(396003)(346002)(366004)(136003)(5660300002)(6486002)(921005)(107886003)(8676002)(7416002)(82950400001)(2616005)(4326008)(66476007)(478600001)(2906002)(83380400001)(36756003)(186003)(66556008)(6636002)(66946007)(86362001)(10290500003)(956004)(16526019)(26005)(4744005)(82960400001)(8936002)(52116002)(7696005)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: pGBbwV5yUYfWgnFMouXx/T3LE0f4rrAjutLNPuwGnqWzeaoyJPq8cJS0X3Rn7pNbGj//7RqAcqQ3V/WuS73jtpV+5dA/Z2PvRBkUib79qbouCdVKfO0JXlGYSAW8uA36XlVEA7gEh9T8Ek1Lg/xgyKbtSuTyRO0Nt0zhJXNG3+R1a8ytZpm7zBeJLq/My912oBQeXXmsf79wbKYm2zi3NlE/BsNZHYjeT2X2giPbkpHASocVWQMtj1UJQn3E0Qzw6L3SnczN27/d40ylvGg4Ol+l4Mt4JMYlc+H1FK8D3VhwtdfrD3MPKGreG3bvrfO+ZAw/RgK5EKjHvYVtDk0f7SnFhSrI4xq2Gsq1canr1xIhg9VixvaIMKyQY/fFseZxmQlMvyQm/7CRGWBGZ04Q/oQg72e+/4eYJToMyzSCPNCkN74resPRIjJ8FoXDpc3V8IdP4H4tfx8bfOPLaqsx/rA+IpF4pwfVM+qBDP+w5+LYEhQcBogw+t3xVV4mN/Nq7JMir4OEFAUhXDoSoJ1dEIy2fn5DitYCCZ0W5404C1KOTM1tyhkzQR3xd3n8jUlFVNZcXGgdGMZSYo+VOqrikGskrZNY/Xt13HrqdQNOm4xR7tsPlKL9t5wkGN3eQOX55N5BVqLlhrpigEiHD7mn8pKxtFhFH9Ye1m0FA2hZ/b8yuVqlRsC+9NYOFIlzkFSykmHzre58kon14KQAwFiZSFTNtis/Go7SNFFkuWHbhvv4bjpVqDwf+Y1XGCO7Bx39BL4Q8SRlhIanrqQIBPDQ5mnHFbOLojKwJFLZ8fo7dy0ragGiAuCZ/CIufwp9/BCyeR/Nmmu5RHFwKDt0XFjtKAY27/iLa/41dNA3jQp3mKuKq6hxXGR9G7skrJ7pSAS9MCtHfGc4AWhSRa7k6Ak4b0lmSnbJYgqUWJ/5AQthIrfzYRQBKkQNxVQWJITy36RZSuQuNe6vXsISv8KuvMXS8Vk8Z8/o1hHjUtHJ/xRiqp7MIUNgLt2clVEMLmXSGsUe2u22WpfMyJUVZFr/rtlgOHZY71VcRXf/iPTeI4KGPfwb75SObf7+ojuPw0wW3YjS90x0FYbWulAp5oCwbCSZolKztM9F9SS11q5R+xcfjiKgBa1ZLefCoCbNmExRLzShpghCbPuMv8liMgvYOhGeU19JM0Ql8mMxDdWPiDe36RVa56n019nu5pqwmOUBiqPjdTSK3pylShNmpFqH3sJw1WC/mgTdn4w8rtvn8YeoVyDZe5GFi+kdRFekJ+TR9TnARUA7DxY5ZhlRjk2QghdsqUcoPLB7mg8ugZ2cmosywpblWYZrqyTN5Z3TICTDntgA X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: afa23990-412d-4a5f-c6c5-08d8d4635f0e X-MS-Exchange-CrossTenant-AuthSource: DM6PR21MB1514.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2021 23:17:33.6023 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: lD139is5Z3zF0SAEYfq/Kp9a0pyXkz1bAZ9eZDxMV1Mt5/4/32lRoN4yzRaDqXfjoRfmYPx3bwCymBnVa9OImA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0983 Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org The Hyper-V frame buffer driver may be built as a module, and it needs access to screen_info. So export screen_info. Signed-off-by: Michael Kelley --- arch/arm64/kernel/efi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c index fa02efb..e1be6c4 100644 --- a/arch/arm64/kernel/efi.c +++ b/arch/arm64/kernel/efi.c @@ -55,6 +55,7 @@ static __init pteval_t create_mapping_protection(efi_memory_desc_t *md) /* we will fill this structure from the stub, so don't put it in .bss */ struct screen_info screen_info __section(".data"); +EXPORT_SYMBOL(screen_info); int __init efi_create_mapping(struct mm_struct *mm, efi_memory_desc_t *md) { From patchwork Thu Feb 18 23:16:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Kelley X-Patchwork-Id: 384609 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE985C433DB for ; Thu, 18 Feb 2021 23:19:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 46D2B64EB1 for ; Thu, 18 Feb 2021 23:19:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230186AbhBRXTn (ORCPT ); Thu, 18 Feb 2021 18:19:43 -0500 Received: from mail-bn8nam12on2094.outbound.protection.outlook.com ([40.107.237.94]:21217 "EHLO NAM12-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230153AbhBRXTN (ORCPT ); Thu, 18 Feb 2021 18:19:13 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SxlqAVBcEvfQILMZK0UzjCwBlE7n2tIEqqE1jeXppFcv5Ho0B2cQp3b1foyGyGaNJMpWxbQ9S+8M8fcCFajbFPChLPNN5Lb9wYfzD7nxg7unuBaWPwStJmhCwKZeAjWWBpP52A6xOO7XjdcDUGe43QozDi7VLkSK3FF6lZF+YhkIY8IV+adsVierHzTTp2teg1XINf5hG5HB4fwhtsV6mxBXAbsC/EFXk/CYa9pnbdpl2PHk3JZpctkYN0/3KHz2DItpZXy+7qD0zNZ3rWBHY01mukvbADhtipcL/YM9irAq0zhcPXp4rB7ESgANblfF3+XG++OitGld6Bdb4z+XXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zX2YfZSNfDt7JSiF+T/PKQhM6vi/KAM95w7ItZAcaOw=; b=QXMfD6KytQ9HjauJcdaWYvqUNUH9mVkMOd+wK4Q4mYMf7Tr+J5z/9TwFE3Ju230Gs5Js/dLEiq5fLAO4Y4pyCCpSu2bU7uwd5BZQH4YxtycN3esXM9UJP8pVNrvssLlfr7f64Ve5qU9aT3nPEfx+2BLIEQY1C4XNGA/HvK8ia5rFrvJ491FkX78yUOQfH9wPP7KYGTQHqApBpm+gIGaKnbAiH2Tl/mdfCsqphChUL+iJ78YYBogGmmTDY6JuV2kvVUtLuC6fx/ZJEWCecOLxDBpxJrN3r8TqmW2t+6+dDSw8Th8GOavl7MPtuS8u8nDq7/Q7la0BWWBptkb6RKOEhw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zX2YfZSNfDt7JSiF+T/PKQhM6vi/KAM95w7ItZAcaOw=; b=BOa4JIRSbBIL+5isnf03oDxI6CD97xBLEO5RW/oKbmfjhzGC51Z9rQVzWvtWRx5y+lRH1Sf0tx6c4hZXO2kJJ/S2bH6/sLLX7qkDqO9S2CNkqq8IJs5NYkTeAddqURXMKOUqt2lcPLHU88JevL+Yiuw2vc0kf0D+isDFfea6aUM= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none; kernel.org; dmarc=none action=none header.from=microsoft.com; Received: from (2603:10b6:5:22d::11) by DM5PR2101MB0983.namprd21.prod.outlook.com (2603:10b6:4:a8::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.1; Thu, 18 Feb 2021 23:17:34 +0000 Received: from DM6PR21MB1514.namprd21.prod.outlook.com ([fe80::1c32:e52a:6a36:3ff]) by DM6PR21MB1514.namprd21.prod.outlook.com ([fe80::1c32:e52a:6a36:3ff%5]) with mapi id 15.20.3890.002; Thu, 18 Feb 2021 23:17:34 +0000 From: Michael Kelley To: will@kernel.org, catalin.marinas@arm.com, mark.rutland@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-efi@vger.kernel.org, arnd@arndb.de, wei.liu@kernel.org, ardb@kernel.org, daniel.lezcano@linaro.org, kys@microsoft.com Cc: mikelley@microsoft.com Subject: [PATCH v8 6/6] Drivers: hv: Enable Hyper-V code to be built on ARM64 Date: Thu, 18 Feb 2021 15:16:34 -0800 Message-Id: <1613690194-102905-7-git-send-email-mikelley@microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1613690194-102905-1-git-send-email-mikelley@microsoft.com> References: <1613690194-102905-1-git-send-email-mikelley@microsoft.com> X-Originating-IP: [131.107.147.144] X-ClientProxiedBy: MWHPR10CA0017.namprd10.prod.outlook.com (2603:10b6:301::27) To DM6PR21MB1514.namprd21.prod.outlook.com (2603:10b6:5:22d::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mhkdev.corp.microsoft.com (131.107.147.144) by MWHPR10CA0017.namprd10.prod.outlook.com (2603:10b6:301::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.27 via Frontend Transport; Thu, 18 Feb 2021 23:17:33 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 819c7ccf-fcee-44e8-7ca8-08d8d4635fc9 X-MS-TrafficTypeDiagnostic: DM5PR2101MB0983: X-MS-Exchange-Transport-Forked: True X-LD-Processed: 72f988bf-86f1-41af-91ab-2d7cd011db47,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:466; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yiCWgA5SSV1Phi3qN9GWrdQuaKoDwKY0OBYO/ZxL9dj6Cna86jnWPBCWOsbPDgBy7lJzRlIK5G36E/469kCCs3ARcF7alTnimWIehqJSMZwm5cade2FmlEbUanlaxR8dYYzPnipWfDtSzCkQraCK/8keUyMpGoWMRSTBKSnH/U9NWI9Pf2+XzTvho+G4ouZf/w4//9cu5cEJfZQjUPPsYxGnEtSE4RIDZ6FYBJyznqj9BjyWjqyMsVDC5McwWRxt1W2Bwqr/u9zXVp96NSo8itjHoT49x5lWt1CSIu83Ein4xli5L7uC7XASr4vA6OpdFm88aa5fSNX82WkLr7PRUQlrERc3OGDtB/MEG69OjqQKBF4EV3EbuVncWb3RTRQqHGRqs8YT8tS3lNrE2bLTv/Ck24k13Gi5Hqr36JA6EkhAiKl2OC1F/IIIRmWbdHkEXoEDtEa+revi1MwX9uh087ZLcHBIBbEasiB6ZKppUcPalNpWdCDo/5c1VbZvVlmwk9Xf9QhYRLd8V036dgBHlv8LCObCk9fDM1a1rp0CCZOdBxd/c3i73Eo8Y121KLPS X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR21MB1514.namprd21.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(39860400002)(396003)(346002)(366004)(136003)(5660300002)(6486002)(921005)(107886003)(8676002)(7416002)(82950400001)(2616005)(4326008)(66476007)(478600001)(2906002)(83380400001)(36756003)(186003)(66556008)(6636002)(66946007)(86362001)(10290500003)(956004)(16526019)(26005)(4744005)(82960400001)(8936002)(52116002)(7696005)(316002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: B74bl6yUBl5fcUwJQJRJoc5G85Kw8Qn7/fg9m1OiLNsrSR9mRsdxWW/4VLqhoPPrJpzvfrzFJLByoh+jSOZ2KrSwnzwWOBSXTEFC3AM7ugFMnPN6CibyUOFu75VN5CqJCAJzDE5Rm2J8hT4eRBbO12WRf7LrvKrMTNulEdH3ZFeZzYNJOCyDvKTiiJZiJq6wS19lNVqtdUFIgQQIstSx8p3f2uy9qa7dvNvYCjncVmRY8GUokC5Rb8Q6OEZncK9JAWcBa+yELHVlsfiLFvrTPNvrcZgHc2uJUQj8QvIpHZkGOR1jg25pMilzGpJVHnQDVLg8osAOkqY/kyI+pa7pYygPhUdaZ5zk/J7f2dzKDHEht8HA5vkZED7fzUZFpYtc7M16QS+4OWtyHVLodmQqL1gVLymoYQnDmRuFvG6gcNt0BML0rhjWNRYXcHn66pjHkNbhCUI7rkoF7lFZFjWhY1s2w3Wn7OkhzR9yyNsak0u3vGLH0ituVC894JuwHtiMrkqZWJXCp99I68oCd4pku6mMHuI3y7dr+RBHkgNIskoQLbRCYDRwVhZLUHG9I/K8sXQVEpYZsmeE8DDkyZkOmcpB/MjGJtCvSrkDWtjMSYSJ8eAF/1f7BIikqbiRqqJZdz0Jr2zoy97QtBleDmLbP6Ko4wUnAcj3DadgrVuX9bUHVY8FrENRuHxE+rGDdJ860fCLKclf5L6cOdiXPdSs5UjT0LSWcgRLpUrM7Kx2FHzDXDoASrkfqmIgjEN3IKlfgeFPpe41Le7GyEHnNxRgblEd61dd5QK2C7ZeW6Rkx0MkJHdzpX1/ZSDJ5wb3uJWhPk7Cg5bgnZhk6Vzhv0CuRsw4V5IC4TOlu2/rW4S+HvHF9dT5BH99VJTGYn1ZhP0KEuObDKrPtJYOce5u4TSjetXT/VaQTboHWHHNTNj4AXL0yhfMKJcxBAkC3DgzjlPm1S89QiW9kaIvWPpHxI6UJdMxuMX/uoOFA/EKc75jMqb5giO0jQmz1BESU0UZoqjlIXhqafpQwqwu0r41PdiE5kjB2MEuR/opMYO3x3Xz3mqinswipF5tJkHCLL5g2UL5iHSdauZDjEYKGiPvTisf1NPaRKp2CKPXdR4zASqMgNWLb3z//GQ9IxRUC2mk+A1huXOKe0dSBtLK/K2xqkD3LrWr8YJgYNxBnkvppEeyGg8HnHBwcUAgqxR5p5ucAKqy0uNknz23rToo7/KXKl4tcadG3JkB3ligP7r0whN/8RqoPtGL2Dcx2gQhEMcTfdPaTfLzlnTOknC5Z7v2NU6G/H3/G8zvOakVfx9FFt0jLp8fBc7di3/wYrVd0XQ8GTf3 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 819c7ccf-fcee-44e8-7ca8-08d8d4635fc9 X-MS-Exchange-CrossTenant-AuthSource: DM6PR21MB1514.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Feb 2021 23:17:34.8289 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: W29Jng/iSOibDvEHPm7M43RduaRTMP5JKdBiN+p/1n3kzy6RNATEzxvIE9lqafKpgDoOaXTrNM+GaLEKl2Bcdw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0983 Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org Update drivers/hv/Kconfig so CONFIG_HYPERV can be selected on ARM64, causing the Hyper-V specific code to be built. Signed-off-by: Michael Kelley --- drivers/hv/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig index 79e5356..d492682 100644 --- a/drivers/hv/Kconfig +++ b/drivers/hv/Kconfig @@ -4,7 +4,8 @@ menu "Microsoft Hyper-V guest support" config HYPERV tristate "Microsoft Hyper-V client drivers" - depends on X86 && ACPI && X86_LOCAL_APIC && HYPERVISOR_GUEST + depends on ACPI && ((X86 && X86_LOCAL_APIC && HYPERVISOR_GUEST) \ + || (ARM64 && !CPU_BIG_ENDIAN)) select PARAVIRT select X86_HV_CALLBACK_VECTOR help