From patchwork Tue Jul 20 14:56:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Kelley X-Patchwork-Id: 483578 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=-25.2 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 E7C12C07E9B for ; Tue, 20 Jul 2021 15:04:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C1676610FB for ; Tue, 20 Jul 2021 15:04:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240100AbhGTOX1 (ORCPT ); Tue, 20 Jul 2021 10:23:27 -0400 Received: from mail-dm3nam07on2093.outbound.protection.outlook.com ([40.107.95.93]:15200 "EHLO NAM02-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S237619AbhGTORx (ORCPT ); Tue, 20 Jul 2021 10:17:53 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ms+paxf24hgUlzkreFyJrvRJnBVvkYoTU24V/iJFHglkY1CjObTVCFumz95v9ImnBnexfY0pdfDUEoYIeSeMF/F+DqpsEevicfiuCvacg7/x7tFojEMPfhwGZGVDqpgqoxUcxc5ZM/mB5uE1TK7W9j2f1FaytYrkHdYhiic7NN6BnBgwbUpEg0cp1OUIuKk19wLw0Xxo/bt3xxHfYrCoIqygE7znVUVrKOsbd3/C2n2ohnnE/ir4Cg9PtJ++HAKxO31mUkvrT8iYjqUo7EPXss0mNJhbiiKaxdDujVcgJfFoVgD8HnHlBp0TN41L3ls8xXIWzUqMnH4rEiVOykT74Q== 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=3k3Ys3j7pl+EJOrdl6xyQvWnZV/fNj4nZKuAtVR9hJI=; b=R3Jdo2IoAG43t9/KPYEfA2sc/JwbRAwmZK8VdobPFnKpS7Dv3CEY5eA4EfTTpvv3MZHoMoWSfuAiJ53KecwX8dEy2oE6JyfDFSc80lwnKi6x9RwUNzdkNupGfBuQM6pdUyalvvfAGOJs1ideKhb+NeCCbNBleVjSgV6PtyCiv4o+JLopdgsNwizTf+YxnZ1K4viScTFs89mpq/XxeD9dCrneSt7/MCNOZS/ufP2fh60oLDQ3DZCj6/Xv7hmrst25olK13lzPkkcUrxL7i/fwH4WTBsNFh8MmCJF1OUjBpY3V33EhE4SYR+oeNHqe41HhKQPagdIOo1KzpT43ZGxBTA== 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=3k3Ys3j7pl+EJOrdl6xyQvWnZV/fNj4nZKuAtVR9hJI=; b=QM4DPQDqiBHSGkjzxQbEYBlaDUitc6mKQchAmUBF4RO0ScqpDB3J/gKz//0iH6XI+oq1yo8RveF6zeaHD5jNAmVyqy/p9gwDCT1XJbL27sdIqEZth/nDeIcbER5vC9VoIX1c6vluQkWEqMRwEJoqI48nx85srcXp2kuccjKDBJE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; Received: from DM6PR21MB1514.namprd21.prod.outlook.com (2603:10b6:5:22d::11) by DM5PR2101MB0981.namprd21.prod.outlook.com (2603:10b6:4:a8::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.4; Tue, 20 Jul 2021 14:57:23 +0000 Received: from DM6PR21MB1514.namprd21.prod.outlook.com ([fe80::3505:fa47:39d0:6dc5]) by DM6PR21MB1514.namprd21.prod.outlook.com ([fe80::3505:fa47:39d0:6dc5%9]) with mapi id 15.20.4373.005; Tue, 20 Jul 2021 14:57:23 +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, wei.liu@kernel.org, kys@microsoft.com, sthemmin@microsoft.com, ardb@kernel.org Cc: mikelley@microsoft.com Subject: [PATCH v11 1/5] arm64: hyperv: Add Hyper-V hypercall and register access utilities Date: Tue, 20 Jul 2021 07:56:59 -0700 Message-Id: <1626793023-13830-2-git-send-email-mikelley@microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1626793023-13830-1-git-send-email-mikelley@microsoft.com> References: <1626793023-13830-1-git-send-email-mikelley@microsoft.com> X-ClientProxiedBy: MWHPR07CA0023.namprd07.prod.outlook.com (2603:10b6:300:116::33) 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 (167.220.2.16) by MWHPR07CA0023.namprd07.prod.outlook.com (2603:10b6:300:116::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Tue, 20 Jul 2021 14:57:22 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3b9ed2cc-0726-41be-8a51-08d94b8eae68 X-MS-TrafficTypeDiagnostic: DM5PR2101MB0981: 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-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Uf5QZyw+oDtyPWEj87YWtNdgQqYy+5ignClnPWfk+pO5TzybPX5E75jLmdr/Z0Q7H1RXNhB6iG+Ju9tK9eZp6d+wpaqAMUbZFyJEbQNqqkQAvKe5RpqeauIzHh7IZB1ePqbctSTHK6pcNUtfXyNkP2SHCMOgS5IG48CKLntuKqN7uiyzuqEqs1fh+3K9xp0gRL2VbXRT0GPsR9xS2KBVQGzSQrLTA6HDnAiZa//bibF5bZb1nR00S+fn5zeD1d+N4wHQfO/ygZBPlqGngPI6rOOdBsMUbOimowFySmn1FNU+QktlRV+Ea7jlyajUUyAv+7h/J0H3lc46q6XDtnK0LG9DWi9RdCT50FRHkldOKPazmrHtlMUCk+h3bK3dhYe58OqTzDfZmBYyqwPOaKfGLExE9PLcPjbdfOy545j/lDwcruADpmkTErVbQzUQJG2MjzaPPUqBp0Rypt56SRWgVeFnBKrX22I5jtIv8Jd1YS1+nB5op/nJ1iud+qiqdYPxK0DDc2LWpH+FKr3HNUrvwlFjN4iEIcxHO/WaWcT3OCiXls17uw9v/3IGphAIvaEukFIZp5izn3ekO06JNzchJxnIK3GWET34hHKYJVit29DzQMyRIknWQ6o7eqO3mkk+qRoOHXWIm7R1Ez50L+l2ZGwW0jo0HRxnCq7U4ZQfmarGZ9Sx27sa6qjD2dv+gDfkNrXNzsgAfEU6eeDXq8yHJ+4RyF7o84vfCXKeeeDIJZZ3vFcgKMCoBNXlkW2Tz6ErdOa7qmN0YDcOCCNvmtxVTeoQafKw/3W3p4QqtNhvrRq6aiTpMDuEWcge9H1mIY8X 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)(366004)(83380400001)(26005)(6666004)(36756003)(508600001)(966005)(956004)(10290500003)(66476007)(5660300002)(38350700002)(4326008)(8676002)(38100700002)(66946007)(2616005)(82950400001)(186003)(52116002)(7696005)(107886003)(6486002)(8936002)(82960400001)(316002)(921005)(66556008)(86362001)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1egMN0wHDgjdTObQT2CVmp6EExsHYeKykyra9oA/0ExncDfsW9DTYJ0HN07c7D/SDkt/tkQYqV9GGDuEIl5Ov6FMUasnGecSne5Oop8mEumrCFt7Lip3n0JwGCyq6GkZsO8HJm4fhEenrr3dlgvyJao5lEWaAas1GOaRUWExKQMwHklGpiq13SEpPLxJjDLyvIaurhunpW4LBY8rMKplgLUyKHdJw8VAcbX0480lAnumyefK8exPvi7ZxxxHKCt1TV5G1CofWkYggWPUcmpD04ncAZSVgj24uiLEyj7+QGVXybFfEZTTh6O69LW5wJA2fVwht1qSF0JF4Wm0BAurMWwR10QMd1tXHL054N3GRZShUE1sXfP2wIc8fc6z7r98wFN7pZCCC/x447TIvIV2zFWITFpe5afNKos0iMyWrqGecHsb1adHc4VyHsjr7j5hH3YdoxVag8BOPrlVGDVVxzI+8Nn45lXTC6Ph42iljvWjuZW6Z7n8n4Hn3VR/L9baOgvoUbjEIG9NWfbXYzON2OTGZk8SLEM+5d6G/XQBwxy/nGMDJCevlVuDWaOHDeTdko/JPJg/t4bxUfBv0bTXffXgZdl1/mZaNW5Kd6EYEs7nVDXtbeRJ+qCENHk7kCXj1qXuvT6ExV0kUCqvKe6RUhznvy3HFDs8VFpvQ5M9FKekl7uhXtZjJsDoxD92+a8NMhE6d5ubCFgnuObWlAVLe/5oiAT/FfttHIZDDdxle+pemQpXk3IwUsEWo96YZsgN96LKrEM93ACYn9KgPk497cwhKbEv2E3Coe5pb+N3NvE+M2vqf+TgBvydlQhe0JU/++xbWUpdiFQcLCk31H98aJjBUkC5M1KVLGS18eV9S8DPobq7VZq+rrxr33UZ7F5Rcdtjd/RKI9Kmjgbz2uMtLru7LOOoEz+5db1Kbe1eRuRh3SUmu7qaZ+HhjaifQm5S015b9oVJqrb38NMtq2W/VqTouv6l8auTZ+UV6SVZQSJkD3xYgSTUwtDsIewM0kfKoIL5pFfGTnHXpBP/ppQoYP5+XXtvY593cZ5mbQsjEkJ8kYqqj0W8VGFW7xcTgphJ2cSMBAF7M8majJSITSIXZm8g6NWY9h1WGnOEjfjaUR+GIiuP7Nzo39TnplhA6PdUDPpVYUpFb0XAnSwUIjITkaZyGsThjR2aEsnQs4fknjmx6r4dWzLgupwM3L47AWItjokqcVr2rYzOseZCP0xRWQ2ecybH27wgRFTypkT/55QMeqT1G5NGdXnf5jvIDVRaGDF67RutPCuKzC2Rl8PGeqV5FGCF/ck3BHFuhhHIMI9attQEBE7kMCopMw5mUt0k X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3b9ed2cc-0726-41be-8a51-08d94b8eae68 X-MS-Exchange-CrossTenant-AuthSource: DM6PR21MB1514.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2021 14:57:23.4296 (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: YHMtEYjAb1h3afndk+4XirpTRdt5efsAW7RVnNNvQsOj+FkxMNmCsgLHKcW+RsHLSgZ603oSBsduGs257b9blA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0981 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: Sunil Muthuswamy --- MAINTAINERS | 3 + arch/arm64/Kbuild | 1 + arch/arm64/hyperv/Makefile | 2 + arch/arm64/hyperv/hv_core.c | 129 +++++++++++++++++++++++++++++++++++ arch/arm64/include/asm/hyperv-tlfs.h | 69 +++++++++++++++++++ arch/arm64/include/asm/mshyperv.h | 54 +++++++++++++++ 6 files changed, 258 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 6993219..8f6f429 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8608,6 +8608,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 7b393cf..ea7ab4c 100644 --- a/arch/arm64/Kbuild +++ b/arch/arm64/Kbuild @@ -2,4 +2,5 @@ obj-y += kernel/ mm/ 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..4c5dc0f --- /dev/null +++ b/arch/arm64/hyperv/hv_core.c @@ -0,0 +1,129 @@ +// 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 + +/* + * hv_do_hypercall- Invoke the specified hypercall + */ +u64 hv_do_hypercall(u64 control, void *input, void *output) +{ + struct arm_smccc_res res; + u64 input_address; + u64 output_address; + + 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) +{ + struct arm_smccc_res res; + u64 control; + + 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(!hv_result_success(res.a0)); +} +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_output *result) +{ + struct arm_smccc_1_2_regs args; + struct arm_smccc_1_2_regs res; + + args.a0 = HV_FUNC_ID; + args.a1 = HVCALL_GET_VP_REGISTERS | HV_HYPERCALL_FAST_BIT | + HV_HYPERCALL_REP_COMP_1; + args.a2 = HV_PARTITION_ID_SELF; + args.a3 = HV_VP_INDEX_SELF; + args.a4 = msr; + + /* + * Use the SMCCC 1.2 interface because the results are in registers + * beyond X0-X3. + */ + arm_smccc_1_2_hvc(&args, &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(!hv_result_success(res.a0)); + + result->as64.low = res.a6; + result->as64.high = res.a7; +} +EXPORT_SYMBOL_GPL(hv_get_vpreg_128); + +u64 hv_get_vpreg(u32 msr) +{ + struct hv_get_vp_registers_output output; + + hv_get_vpreg_128(msr, &output); + + return output.as64.low; +} +EXPORT_SYMBOL_GPL(hv_get_vpreg); 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..20070a8 --- /dev/null +++ b/arch/arm64/include/asm/mshyperv.h @@ -0,0 +1,54 @@ +/* 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. + */ + +void hv_set_vpreg(u32 reg, u64 value); +u64 hv_get_vpreg(u32 reg); +void hv_get_vpreg_128(u32 reg, 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 Tue Jul 20 14:57:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Kelley X-Patchwork-Id: 481831 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=-20.2 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 A9EDCC07E95 for ; Tue, 20 Jul 2021 15:06:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 95D3B60FDA for ; Tue, 20 Jul 2021 15:06:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240077AbhGTOXT (ORCPT ); Tue, 20 Jul 2021 10:23:19 -0400 Received: from mail-dm3nam07on2090.outbound.protection.outlook.com ([40.107.95.90]:57825 "EHLO NAM02-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S239118AbhGTORx (ORCPT ); Tue, 20 Jul 2021 10:17:53 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VTng3zLPfomOnFJoJugBAz+C1CBG30a1qh+e/vFP5uvv6HKlJ969h3TuCnyOH4U8icbYRUxJWOKnmUtzE4KTwhC0jtYcS1Dkj20ij97gds/y/kGOyp7RoObJe3kQTfqFUTdqBb0QBjBoPesPmuIb6EWh5j0n2arkTSS2RaM+yRAkWWQAop2TteF24XPsHv1ocfNnaoAZXDKhNMDj7HImqqcgjIRXx10IYZTe29XaCAxsYkwpcfWuCVRG3aHMi07g27odlMeYZXuY0ZBbEZ4yjF52lvpCuwkZFscwZQ0VfqN8J7QyAXw0gAML5noCjnA26V1EqVeB8TZbf86se/0pEA== 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=WuFWaHyaNoPq2Yo41iX4G9GZNIw/9Q3IvwLSkmfIsOI=; b=Voj1fmt1m28uCPaP1VSy0i1uBBu3pDqkXo5PONBZ5pXRk9FHEQJ7Vop3HpOGULk190vxf7VGppE306SQHS9AxkTsnEt8UrqD9et+nqqYD3hv0J2GrYEekRw5ZwU8e40Lzl0f32BYJv3o6aY4pF4/czqQUcyICXz29wCrQIWTc+xUyT4OqSlIjXePpgcbnNsmuyAYOKKpy3GFF55he+B8b/ke3LMa31t4ARCcmA/+qYsAx+KHxPB5M+mprQQyMjEHc67bp/dF0g8f4WqRZfQZS793UUJdknWJ9seW8Fuy7Gvxyvl0TNCp+kOAuiXj+cGyARPUoX9XvK0tK1UjcC2hqA== 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=WuFWaHyaNoPq2Yo41iX4G9GZNIw/9Q3IvwLSkmfIsOI=; b=ZzNhsPwYO/47VvL9R1DwKdrU3tfGz4OVZGDNdQMUA66mUNv//nONl6JKxtKjbEjRvbqqPGHJK1oOCHxV0X32u0njiban38fx0fUxiUSUwHw8f+9f4UDo7DI9By6nAup1KU4+ylKe+KP25eMul9QpIRO6Qf6L4LV3roxgPKkW+To= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; Received: from DM6PR21MB1514.namprd21.prod.outlook.com (2603:10b6:5:22d::11) by DM5PR2101MB0981.namprd21.prod.outlook.com (2603:10b6:4:a8::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.4; Tue, 20 Jul 2021 14:57:24 +0000 Received: from DM6PR21MB1514.namprd21.prod.outlook.com ([fe80::3505:fa47:39d0:6dc5]) by DM6PR21MB1514.namprd21.prod.outlook.com ([fe80::3505:fa47:39d0:6dc5%9]) with mapi id 15.20.4373.005; Tue, 20 Jul 2021 14:57:24 +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, wei.liu@kernel.org, kys@microsoft.com, sthemmin@microsoft.com, ardb@kernel.org Cc: mikelley@microsoft.com Subject: [PATCH v11 2/5] arm64: hyperv: Add panic handler Date: Tue, 20 Jul 2021 07:57:00 -0700 Message-Id: <1626793023-13830-3-git-send-email-mikelley@microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1626793023-13830-1-git-send-email-mikelley@microsoft.com> References: <1626793023-13830-1-git-send-email-mikelley@microsoft.com> X-ClientProxiedBy: MWHPR07CA0023.namprd07.prod.outlook.com (2603:10b6:300:116::33) 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 (167.220.2.16) by MWHPR07CA0023.namprd07.prod.outlook.com (2603:10b6:300:116::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Tue, 20 Jul 2021 14:57:23 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6ca4d9c9-994c-45e7-fd90-08d94b8eaefa X-MS-TrafficTypeDiagnostic: DM5PR2101MB0981: 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:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: j1NMPYSzqXNNSZwQbBSpuK1pE4dNZj6g4n+9Z0Rgww0fevKsVjKiz23sRaHLobS9zKgxEbCQ05c+ctxHC+hhADS1Fv7dsbjLVitmv2Liz/5BEZrDX4LVe8TwpuZyfrXmd5iR1b7IpLIVb4ZoqzOFZBm/GA+vv2yiCfMFxtSHJBWsQp2YT6xRN2Rr3ZWFMZ3PO5jRyme9vh7f6kDzBin92AgkztPetP73LummL6QrjwSOWH5ZsEFuSc8A73lElyolysZYm1Vil5CBOZm6is8WjG5oZrm4usG2CA6vaR2i3dK1CmEIKGpWcYDWowYIocHPTEVEAQGbdTx1Af92vVHgb4ESBevROuUwf2lr2ZWGvzjNl9W/sZOsTuJ77NjlTPob7dmYuQVtBfA67nfiIr0mQ926n/XIs9yeOBKHmw80mh124QxRj2ElubruZAIdVBPxOw5wO2HwyrCIaJ0jtosjLTeU8wVT0jlRVpNzSIug4PQzGLEgFdEZT3FFi46gLEbkc6dMZb8LjUD5yMq33dX67l+/EiPNcWrnD3x3lwid1I4oB1LmjFLtwJtWQMQiFvujRAnBvgzKSUbctbsEBJ/l5WdX3zOO5S1CczNNsWm4RE7iscqe+sw0iHKQoeTakJfn9HMjF5Ye/CGifGw6URleMq1nhDJ0RQdqIKCegJot8YhwoONGLq/RaPxFYQB4QCVNWvhOXkz8X0QhDLYttPI2vDcupWGiTi421n5c+EjXdhU= 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)(366004)(83380400001)(26005)(6666004)(36756003)(508600001)(956004)(10290500003)(66476007)(5660300002)(38350700002)(4326008)(8676002)(38100700002)(66946007)(2616005)(82950400001)(186003)(52116002)(7696005)(107886003)(6486002)(8936002)(82960400001)(316002)(921005)(66556008)(86362001)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: sec1WlMh/DHDTT3XbIWy7vQnc1XnIl90aiFqZv3KhwM9tgKXu/ychYMdRDzkrsEmbMi9/m7exxs+AKhX4zvd6TOWM9WKaoFbHch8rYOUAcV5RfkLEgEjbMaDStpy6RQot31UsPiY2KcHwNa3bb1JOXiz2rZ6e0jbSw7OQ2nvuz4spJz+e7f9C6QIc3n6uXM1fLPSpPJjAYn5WHMSu/tLSask1n+ApAKMd7CMDTVu+e9DVNuWiAew0/svVXDZk/KEXIP0IjV8yC+ejO8Giwq9aK2hQJK5q9gv3imqupUJicyZ9FZWFcHJ5KdmZ01laC+o9RxyRA94UyJVMBg74N/iGS0d5b6YUhVpliR2/wjydBT+5ZVcmIsnmzLHfAnyQ1xspNyt+odvg7qjAlUDoUgcSuthmyjUImOWodEdpfWc4GcFxh+Rjbz55v9lhgTvPyLWViEG7CdlLog81FUT+mT649XADj4L+Osb84Q9txT+D+n2ghfzgW7nboZjNhvhNhLcF6mWWyMUvHDiTMrkUAsSzE2kBJt8gyje7PsEMk3rmJZ5mW/9pPnJgt/iUkdO+xcopaggAC4lU88YibRFE8V0F0CtwyZS9nBaITEJ3d4+75YtE33dHayOfmpF42n9C7wTaHmvrNIZd+wdULC/Abhs4y67iSBWuuAy8ixTWmyXKoA3s0U02cZDE9SgeGJk6RV2mCB3K2couJbiEdtIQE5QANKerEJ9VfG+wbfmdK6jqZ9QLqsHNBvhJXrmOazVPpJR0CzQ0IMNMgLgJd49uqpmnzxVmmp17BjMOf3+GzmWezXFZcm8NnWBov7rjQJOsMt4XenFhZwmv4AcCM2kH+OJYDhfPAFkBm9p6EBIBro56HGXyPypPNci3HH6ZVsK5jmepweCv0Tlc/CS5qx9VI9HPEGHNwKBW0Zqb0ii5pgyP20l5YiKpkQkhvO0e0owz4cwwWHReWKGMlNdwdpFyX3KBt+YqLUQezdKI1EdjRA6ornTq8IjHJ2TyhGXoXx5/T+IdGP7I2oCSxszdp9uUKvqqAYD3Ie/ve9BdiCSx/74QCJEXR4AHCUh+wnQKy56iiPjTzV3+gZm2bIA5v0YG0A7kr4eNs/p/su0LNrajd3aoVfCObKxkPqjzjBaSeWaN7mYWWM/5fHac+o3qw98+Rc/nadYkArNoHYidF7cj6db7D8uwF5VuwfMuXeyMqwMGntGv1+IMsbl8Vn19mmk1VmViPgx1bvMADLh4tVWARgecF+sOf9ei/aYQEFIJXn+ZrKD3pPS3wwxAJPu6McXKlnxI1BzmRBhvaZF67uoANUtPEZop/9PAtx/qSONhOq0GaMU X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6ca4d9c9-994c-45e7-fd90-08d94b8eaefa X-MS-Exchange-CrossTenant-AuthSource: DM6PR21MB1514.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2021 14:57:24.3834 (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: qafxP4iJu7l8uaEWwWE+r0t6H8p9cZ7l1pr39ZkYQSyBLzoLz3lVGQ5BUfzOyI1opAVE7ismycCZXEyhpPSxmw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0981 Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org Add a function to inform Hyper-V about a guest panic. This code is built only when CONFIG_HYPERV is enabled. Signed-off-by: Michael Kelley Reviewed-by: Boqun Feng Reviewed-by: Sunil Muthuswamy --- arch/arm64/hyperv/hv_core.c | 52 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/arch/arm64/hyperv/hv_core.c b/arch/arm64/hyperv/hv_core.c index 4c5dc0f..b54c347 100644 --- a/arch/arm64/hyperv/hv_core.c +++ b/arch/arm64/hyperv/hv_core.c @@ -127,3 +127,55 @@ u64 hv_get_vpreg(u32 msr) return output.as64.low; } EXPORT_SYMBOL_GPL(hv_get_vpreg); + +/* + * 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, the PC, + * and the SP. + */ + 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->sp); + hv_set_vpreg(HV_REGISTER_CRASH_P4, 0); + + /* + * 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); From patchwork Tue Jul 20 14:57:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Kelley X-Patchwork-Id: 481832 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=-20.2 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 EFF3EC636C8 for ; Tue, 20 Jul 2021 15:04:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D332A610F7 for ; Tue, 20 Jul 2021 15:04:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238329AbhGTOXa (ORCPT ); Tue, 20 Jul 2021 10:23:30 -0400 Received: from mail-dm3nam07on2098.outbound.protection.outlook.com ([40.107.95.98]:28896 "EHLO NAM02-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S237636AbhGTOSe (ORCPT ); Tue, 20 Jul 2021 10:18:34 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VSl9huDf7d7b+aGy1glw+2cnTR+o4MGjpZsh2Jl3RkWzSTB67u4XTM5NMECwmAwxsL0ginEjzGn4chMOGkMhMF45bO+0wr24fObyLVJnXXtY/PYGR7EGj/hHwF3ewAVgzet9x369Dovu5jIjb4pqhJyg2aFwBG7cNJCf9cOQg7EWAtt2O5wL959d4bMaiIKjJySn3WWVs21MVP9jMLde776RoUC3I6HlK8XBJaGnKaRm+KZKuFCHUX3ARMPlmgLKDOy/DV2sEygD32LFCl9fRPrgFNwfulmyW13WviwmWnopNA8ge4ZaYKcX/gt9CW4sm/4lAkx2314SUY9vuy2hLw== 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=1HiU6XS82HAdj4fww7xmvbixCsaas4zL7arlWJnpwmY=; b=lRHF18iHm+8ranSkqKRgH+pzs2yWroI4FR475CVR5UwvYJyfpkQbEph+sNDaowREx54V07sSf2+9BizS8la+SlTtc2y9NleJAjU6JxP9AFBGOZMI5YjFElatHgLx50SNf7X0Ccf+398rQ4ce3qzef5eIb+IJDS5THkDxtxQey+TwKsEEpCc6K7q8PMyMSt7/rrguDOrrcPKQIavoxxjs8PgOKAkwkFgaKlhMEkLBm8UmUhzkTvkqG3cWXUndw68u869llChunakp4XHZqxGndPhS1gVW5vesgJy6RU/x+Hol2dDL3NONDI8jpeK3DH3FJRUktTHPPxeDSQjejRJu9g== 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=1HiU6XS82HAdj4fww7xmvbixCsaas4zL7arlWJnpwmY=; b=K0B5wtsLNTB6J9yj6CywetJu/CQj7ir7zVnNQW9qkUl+X2b3nh4IVBlz6iDWeY4azCam0XyCYFwA/pK37NkisyB//Rzw0xZT51o/jWIZ1s3Eu7STd7XrSVkKl0e2ttkkBenNdtWeQYZ9jjVww1Z/xkmFtBInwwDcZNLmL99RMUA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; Received: from DM6PR21MB1514.namprd21.prod.outlook.com (2603:10b6:5:22d::11) by DM5PR2101MB0981.namprd21.prod.outlook.com (2603:10b6:4:a8::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.4; Tue, 20 Jul 2021 14:57:25 +0000 Received: from DM6PR21MB1514.namprd21.prod.outlook.com ([fe80::3505:fa47:39d0:6dc5]) by DM6PR21MB1514.namprd21.prod.outlook.com ([fe80::3505:fa47:39d0:6dc5%9]) with mapi id 15.20.4373.005; Tue, 20 Jul 2021 14:57:25 +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, wei.liu@kernel.org, kys@microsoft.com, sthemmin@microsoft.com, ardb@kernel.org Cc: mikelley@microsoft.com Subject: [PATCH v11 3/5] arm64: hyperv: Initialize hypervisor on boot Date: Tue, 20 Jul 2021 07:57:01 -0700 Message-Id: <1626793023-13830-4-git-send-email-mikelley@microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1626793023-13830-1-git-send-email-mikelley@microsoft.com> References: <1626793023-13830-1-git-send-email-mikelley@microsoft.com> X-ClientProxiedBy: MWHPR07CA0023.namprd07.prod.outlook.com (2603:10b6:300:116::33) 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 (167.220.2.16) by MWHPR07CA0023.namprd07.prod.outlook.com (2603:10b6:300:116::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Tue, 20 Jul 2021 14:57:24 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1b8d6978-8505-4a94-db7d-08d94b8eaf8a X-MS-TrafficTypeDiagnostic: DM5PR2101MB0981: 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:2449; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cjZR65UjztKnY11MuSdKui8os7jbL3rtIq8I6OSqPjuIHuPpBsRK2HlHsNMYOba8wVCSty/+rq77oAJMhg6rtcugEg6RAuHvB3hOrwn0/jf5rUh968lagsEJ4tV9wDTboFgwobKPzwgBVuL80foRxsWzk9NHaT9clFGkivJv5OrcjWm28fvrRks+5KiIN6O0qjhP2ePvGaDC2qNuIYcc4FQ3BVTjDPm1JG1r8HDCHBfaGTN8kIWFBiqXnfM+kP52JIARHr+Wa0ZLpRsTs50aF9zzfrCFFXMICC62QkYhIEHS2gvFqWqNeyP2AWVclfYdoRd0flIpFGslvZxDj1SjRuUdFTxAPQensiomL45xgTTJADSBL2Yr3qyA09hMxgkLVsj2ljjqdV+Vhmugd8QzVKtVXaMKUcw6N0F5ydOSbxfivlE4Hc/oQkyzRkoMGahxDV58VpgIVNZyHS/MsMaZ9Q9Ygvd84vHse8oOP8EfGYE9QitCzMik9syl9vWJ6JQJBZPC3B1dliyvDKHrBZlr4BA4L1sY5+W9VCfmVmtxk+ILCe3S6c4ZuNHP6AngglkQku2LiOk14E0Th2rA2O7RjdPxM0oeapy9BADzI3E2f35x3ieccRTxjJ38rN82SyTqhmhRZfQmixqpE0WXYMXFT5SEOVmDJhAPGuHum1aZgRddz4M4L2ZXO1TFLvOFd3sT9HB7yYqZc1x+PeG/vRBIQMmhkohlAcfq6TdmNoYuXjY= 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)(366004)(83380400001)(26005)(6666004)(36756003)(508600001)(956004)(10290500003)(66476007)(5660300002)(38350700002)(4326008)(8676002)(38100700002)(66946007)(2616005)(82950400001)(186003)(52116002)(7696005)(107886003)(6486002)(8936002)(82960400001)(316002)(921005)(66556008)(86362001)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZwBzX8mTmywXKH5p4rsThRTUXDaNxcJn44cwfrPSCfy0MBbX/sA0XVHLRl2A4XmnIqAeYdgtMclJ+0tf6h0ICkzFuDxKNe1ZMqDSH9fjEx0UP4TpxEi8gre/WBOPrC104k1Plj29cgdrB709k+jYAuGTlXnfze1PEfuopYqf8GfirX6pASnVlM9Tcktz9cTUvpSb4Ag3c/jXezKVhTRiBpNKu+/0jZHgJAf92G7BeGKFDJrqfr+UMFAhkhTf/WT6bvGbx8kmGU/VDaXKmRVWgO+nzuNfhbmivpwSPNPvoUuQUWtQL6G9Pnf86Q0mi3U5mz8wvRyclOmeEjM3zkXkfzHVldNFez5DUtWMHY4scjhED4zFVy/lpkf7ISwEoTKdLQTGidxPpkc6BNm5epZboWhmfjqrqkf7xsqHyyJJyxT9UU10AKHKxo1LWxMd/V4cHXceLvEv9CUEfoLDJdOMPDuquXjc2gEmkt0srBOQXt5ABlR1+qTAXY2rjQqsY+X/IjA6vTaQdoelkooQAY/Nrz+yiMggcfF+AUnzYgHHizHSwq1CNPo+KsgOu+cUKxLDf5jmb6XDKv6AgbW0t2/48EBuEccIprDL/yGheVvWWr9FiqyS4hikx8SYln9UoWZH2onbewWhUPChkx0Rc9bcylxBPCRdtUSupAIKVVQ8OkZBL2GFzMdS9gVxVMVfqKg6uERP8GXjZy+arn0Ocz7gcYw5v91Qm+z+EF3vgJ75z/GZniL81zD32oVKaxJ9ia48JJaK/acQ8yRMzihw/eW5JM2tBpKmEsDPCRNQFdMA33o2FOhgs2yrTZ/Yf6875BISh/EYvRZ3X+vyU7VqWAzvHrOz/VoMFYMS3EKfWgEIyRuhVK9ecZlirmDX82tza2mUdZMuPKKqlv5hVhm2yrrsQOj9M7Y/+ZCZ1zSYjw7p4EpJ5oH4Gyy5fypAr8CbUIdCHH25voto4sJHw/i18F3C96edsISu0yWoQdwaLZzCYMJATc8iSClUplKn4Tv1Oh8ysJuHSsNelgi3A74tM7ua7uZSF/fV+EW4cRyzrAYRcINuEd20E45Uj6eoN1+TeDDgrdK3L4Y/iwYjNOrf48ylkjtyniecOW1Ze6rQHkRmXA5fMvqG61KeHjvAsj4f5bIemK1F4YYHDfqnXdoDJlSx5AycHcq62DWjc7UPDvdzpyDrnc3viVj+uL/5jMyRpApAnGPa7h35Wpawl0SkNI6IPm1e3kbDKaB/CB44GQ41r6cUXNvhK8VAx1taCo8hCTa1Gsh1WJmD7zFEox6o/oUjYv6VVrjvYrX1+lEmpqa0uPMU1sUSm83ICgPZjum34djr X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1b8d6978-8505-4a94-db7d-08d94b8eaf8a X-MS-Exchange-CrossTenant-AuthSource: DM6PR21MB1514.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2021 14:57:25.3661 (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: d8PkzWOjLzrsRrsYK1ZYyGfJH3P5O0Ka1GosjTZBi5ZalUR6m0Vba844ANLENLHyNX3rhMKwJ2pPwfsCo/CVww== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0981 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. This code is built only when CONFIG_HYPERV is enabled. Signed-off-by: Michael Kelley Reviewed-by: Boqun Feng Reviewed-by: Sunil Muthuswamy --- arch/arm64/hyperv/Makefile | 2 +- arch/arm64/hyperv/mshyperv.c | 83 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 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/mshyperv.c b/arch/arm64/hyperv/mshyperv.c new file mode 100644 index 0000000..2811fd0 --- /dev/null +++ b/arch/arm64/hyperv/mshyperv.c @@ -0,0 +1,83 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* + * Core routines for interacting with Microsoft's Hyper-V hypervisor, + * including hypervisor initialization. + * + * Copyright (C) 2021, Microsoft, Inc. + * + * Author : Michael Kelley + */ + +#include +#include +#include +#include +#include +#include +#include + +static bool hyperv_initialized; + +static int __init hyperv_init(void) +{ + struct hv_get_vp_registers_output result; + u32 a, b, c, d; + u64 guest_id; + int ret; + + /* + * 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 -EINVAL; + + /* 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, &result); + ms_hyperv.features = result.as32.a; + ms_hyperv.priv_high = result.as32.b; + ms_hyperv.misc_features = result.as32.c; + + hv_get_vpreg_128(HV_REGISTER_ENLIGHTENMENTS, &result); + ms_hyperv.hints = result.as32.a; + + pr_info("Hyper-V: privilege flags low 0x%x, high 0x%x, hints 0x%x, misc 0x%x\n", + ms_hyperv.features, ms_hyperv.priv_high, ms_hyperv.hints, + ms_hyperv.misc_features); + + /* Get information about the Hyper-V host version */ + hv_get_vpreg_128(HV_REGISTER_HYPERVISOR_VERSION, &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); + + ret = hv_common_init(); + if (ret) + return ret; + + ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "arm64/hyperv_init:online", + hv_common_cpu_init, hv_common_cpu_die); + if (ret < 0) { + hv_common_free(); + return ret; + } + + hyperv_initialized = true; + return 0; +} + +early_initcall(hyperv_init); + +bool hv_is_hyperv_initialized(void) +{ + return hyperv_initialized; +} +EXPORT_SYMBOL_GPL(hv_is_hyperv_initialized); From patchwork Tue Jul 20 14:57:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Kelley X-Patchwork-Id: 483576 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=-20.2 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 BECD0C636C9 for ; Tue, 20 Jul 2021 15:06:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A2541610CC for ; Tue, 20 Jul 2021 15:06:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240103AbhGTOXd (ORCPT ); Tue, 20 Jul 2021 10:23:33 -0400 Received: from mail-dm3nam07on2135.outbound.protection.outlook.com ([40.107.95.135]:52672 "EHLO NAM02-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231993AbhGTOSm (ORCPT ); Tue, 20 Jul 2021 10:18:42 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nbgJiCE7HU//XoLTdsPR2cNCetlAIr5CKF2s/LH2beAPKGa8dU0oIAKAIMkehAwFWiokI1QM7JhLWTv6q3LeJO8DoGzp5jQJj9JRVUR6G8qYa2gTWpkiLM7lkRdYW4W2U2vngBMIMsIrkd7WzF/pJGqa4D3bsT382nAu55jd3UEZt8TOQda8m5zD2P1yEaIJYyM/zvKyd2PCAGXp5aHL7GRkEIQeCZDMSMKbRH7WKM176YizTgMe7tPR/UMDDSi4R0lu5aG/qix+4fwERJYWt09+lBNQpwVUh3op7oWyB/YHqwUlHW4VOKPbDjulX4VtB1Jz7OF4aRkSR7n4Lg/l5Q== 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=pSKE7KsZhel89WAklbG+zH0DgO9IbVC7ODkZQ2KYEmI=; b=GDXO9P1UKDF22Hu+oIUL4TFxLAvRfSsPEZAPiFMMp+pUE0aqMTRzunNDd8UvnJSBg7MRNIClnR95k6hPiaVyaGslKU8nBP80wp4h0T1w14ygOq9c1qXhv5mJS5iqX0k1DW1g/jp5rQMhw5Qw9lkAHZUV0SXFRgjxGyDmj7pfxKcUwRM63azudjZaRTDMKi/3GORJWIWyh88YURTqK1gpX6fXMG5Iih9wDhYCJDpQQB/DysHMqSWXFJ1O3YMS0vKFHxQwqbyyd/fnwETYOTc1yP4UAZhomtl46VptCzhTShcmd84C++hCIgu1pRLG/27lRd/P+0ggubsuQcPPiBVrKQ== 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=pSKE7KsZhel89WAklbG+zH0DgO9IbVC7ODkZQ2KYEmI=; b=Vig4/rQdUXx53t34qmoOt8Mb9pX/d/0jYrBGgbJhJvfcqocp0qIG9IOqY8PXsM2JOZExLcg99U7C9A4q42Bf++tuy7WUsRvfZ6Al7nCTJJV71lg6+R5Y4JRpa8r00edIV8UU58zjhJX/jorj3HSSr4wH/6Be6GQ6R3mGEyJhmLA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; Received: from DM6PR21MB1514.namprd21.prod.outlook.com (2603:10b6:5:22d::11) by DM5PR2101MB0981.namprd21.prod.outlook.com (2603:10b6:4:a8::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.4; Tue, 20 Jul 2021 14:57:26 +0000 Received: from DM6PR21MB1514.namprd21.prod.outlook.com ([fe80::3505:fa47:39d0:6dc5]) by DM6PR21MB1514.namprd21.prod.outlook.com ([fe80::3505:fa47:39d0:6dc5%9]) with mapi id 15.20.4373.005; Tue, 20 Jul 2021 14:57:26 +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, wei.liu@kernel.org, kys@microsoft.com, sthemmin@microsoft.com, ardb@kernel.org Cc: mikelley@microsoft.com Subject: [PATCH v11 4/5] arm64: efi: Export screen_info Date: Tue, 20 Jul 2021 07:57:02 -0700 Message-Id: <1626793023-13830-5-git-send-email-mikelley@microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1626793023-13830-1-git-send-email-mikelley@microsoft.com> References: <1626793023-13830-1-git-send-email-mikelley@microsoft.com> X-ClientProxiedBy: MWHPR07CA0023.namprd07.prod.outlook.com (2603:10b6:300:116::33) 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 (167.220.2.16) by MWHPR07CA0023.namprd07.prod.outlook.com (2603:10b6:300:116::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Tue, 20 Jul 2021 14:57:25 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b101a304-ee10-450d-0461-08d94b8eb022 X-MS-TrafficTypeDiagnostic: DM5PR2101MB0981: 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-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: o++JZ8PyuVEZo0u2gABep08UbPY1OOqGJ0BslIsBop7VhXRm0YBUrwG/cqCv0aMw6kjAMxEORjp8RWMd/rlZKsiQu3PwDHJIYX8LD1lhx2fTPQdLJF08jeGl7Z9dtvQBzN0PhS2XaE0cSU5WjGYYHhzBFm1K3qeDQgA3/uszweE1n1mieysjuVpwLUTFkwnEWAVO46lLKUSCxaNm+X4wGPxnbGMhRf+r1igQSXdfOwmWtkJWEg0XQYhbod2yumFyyiMNufwrtW/NWP0WWfoWLBLKb5Sx+cUF+ve4MD4hBNpXS1wbE2MQnlfEWVDQcoepmUDOmSecURrxl5ML/3OPsHwyudL0RZw+gAnPaF+79eMIBOtOS9hiTkW2ai5KXs+MyFvh8IqRzr/h0KV5OQmWGRa5sEStmAhCvzfs2tZ+dB5I51U4Rgny0ZDI2o1gMo+70RdhSEjClLK1QjiJNMNwTw8+8JeGhDSHHYeGZ/ptsgv9EPdm1jpCcrltN7kXIGc9I7gV/4MquAjsVWWqqW9fBwoXcq5qgSr6mDC3KbAH5mYs37kvvzYqLG8R1NUukOZy3HTqssK/cwer2qglPR0DTtkIGmXGomPg93j3fThU9JE54jFFta6SRReoe9Vw0+yTzJEOM50+r3essfKeBQEmkm35gidTr7SPEkiLDPF51Z+odNapVIH4x41NWDXBU+A83Y24bPZcV+vr8jtkHTArxT3r7PKqIKn8j399Ot+t8T0= 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)(366004)(83380400001)(26005)(6666004)(36756003)(508600001)(956004)(10290500003)(66476007)(5660300002)(38350700002)(4326008)(8676002)(38100700002)(66946007)(2616005)(82950400001)(186003)(52116002)(7696005)(107886003)(6486002)(8936002)(82960400001)(4744005)(316002)(921005)(66556008)(86362001)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /kFzve2X3W3orUMoFqKTYzQz1TCuc2HIT1RVyT+MZZ/WkN1S3Emu7EniEk5cmOp1hWmxr6YSohZGSmQdLM/2KYPdV5EVYEdtGXSNnX9vrSeGGnghbVm8K7Idf6nvrG+30UnWNPNc7x9EwLbdD0//LRREIWeulli0bY/dYMSo+u9+y41oboyS6xt8kMhwWirHEmLUnMLsJyt0GzeuH5Qz02xaEdsQZ4fYG1DgWzFhjuVIOHcbtNobNECUGayEjtwr0ODKsOC3H15j1V1DwD8p/tTezJPmNn5/jcEgz+A5ddMWt4HGuEfOhCV5ZJHxMDQRXbDqR8KwmRr0N4KeuFsW3bJvE+w1xD5eldCqo4aGrc2+eB5aiOf25nGHSMlaPgLgTC5hVVKjdgupNJdTxIEjPM40nf6zqvaJj099Kpze/0v8im/ZSpCMIDLVCxuEF6CaG8HmFNrTGSd12EA3hIACP7QLSaygEeWZ2p/9/KmcYziwFz8/dMb3IriTIR9Jm0e5Fc4FSgiAJu6YrVBhJ7icQJcUVJrZBzDkJN/wsF09dqhEZa2PEbqGA9lwCvf1MzRLUew7NcxXuKD/7fr6/Rk1pN2vdzcjI6u1wjtpM2pF0HnOOlqQPem4NOExm3R4NwxNPrU0e7d21sJt2E8PVngTf+28TPj7Nbi9iryYKy/Bw8dwhzX3C05crnBrBcNK+2sGsciQTr3VogKuWaZiRPCqmqcDHDCxJ2eV99Ml0dxHpn4xdKe5M05CcpwYlX+S/InSzO+aKLsAg1DUzrZtvIWcLpwwTJS7h3Ml7NqSMs3jDQmfvG7RqJLPMKbzNulNxhDKV4ehNJ2LafvbuzrObU7t+rFh6Iq+82K64snc3zKDpRP0cI5aD5wLA90u7HRphobTLLKzMhBVEYvluAOWyUrM38ncdDIe4LbSbKzdnnMymu/taNnqhiIpSh2OFl6hX9eto68mN/C9ovB5mtr2llzz7r62W5YWBEaHR25w0AwCNLpY1yJSQf2+WnQvq03QAHzLx0Hw0W0vxhBAz6l2VJiP3pHUmliePznss6+K2wDzFUhxI4+v6IWuHejGXAKOEFC2jUImMofGXDkd5W3cK/n+NNRdWRQ44jnoDlpgjInehujfc5+UIXUS9HK4puxBM13irctQMO+tSDVtRY9OsNOL4OqGiXdfeOqMIIj7ei2FBwehHQE9MuzcKAuniTUURhEekv7k/cpEFq7W8zB9VndhB1+/KgVFaqUUH1F9X75aVg4MIrMNyBPeVE0j47mMPw3usZDUoXzzKstcBJhJslAntpckyKzxwR+5LXW2QOB8ZrPFalbbkgxmyvmMw/jwqfZN X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: b101a304-ee10-450d-0461-08d94b8eb022 X-MS-Exchange-CrossTenant-AuthSource: DM6PR21MB1514.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2021 14:57:26.3438 (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: x9WUHnXrSSIzIWHCmzUgSr7BhRwQejQMsQXHNmYua/NkMqLxMDxlubzaOv0b7POZ+roK1/vQC342+9ERHGZNSw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0981 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 Acked-by: Ard Biesheuvel --- 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 Tue Jul 20 14:57:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Kelley X-Patchwork-Id: 481830 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=-20.2 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 C375AC636C8 for ; Tue, 20 Jul 2021 15:06:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AEB7460FDA for ; Tue, 20 Jul 2021 15:06:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238159AbhGTOXh (ORCPT ); Tue, 20 Jul 2021 10:23:37 -0400 Received: from mail-dm3nam07on2104.outbound.protection.outlook.com ([40.107.95.104]:14017 "EHLO NAM02-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238580AbhGTOSt (ORCPT ); Tue, 20 Jul 2021 10:18:49 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cH//PYv3dTGZF+X5zwME+EnYdT+n6iNNK20913hIIebTuOPRCpDVu49KKhLmybuFf//hrr9qWDAy194v6gAK/syjdmLFFIbAtdyR8NZgYrQm+5hNNLwBaHCyJ5KSUrWfoyneVMZ46cJqKqq2+gJeHxT4z/QZ5JS2xv0IuM+XJ1+pC20KSSZCsGnIAxr0q1MTDXvj1zdefFUod9KpcAwr9PTwV9t42jB9mh9GxPC8BilV4QtG7DKkvJo4RnjtpNfvxTik9YTKQJqve6x7BvpZMRVTnlrLxLZyfaJwZ/wZR4iwSOwQnPoXmgMbAPqMdhVlgtswQ/y1Zci1Sm0rvNCSkA== 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=8xnCcy767WKevDP5UhHtnUI+xPQRl1REcs1nGDGtkcM=; b=VRP7phQvJOlDO8r+aU4/jOfao0fvJjP56nZak1H6hiQdGJGL2nI1A/vH9l/DXMdqPcl8XHleos67QPTHpl+9bYCaBlVFNbAptYB5MbMOdp7vOZWRGjaJqgQbecTU2R1NcQi4UUbsNMoPGiNn9ltdAw7bq0/bNaufn465RMe5WF8GxzI/OLdfozOjyYrkw1sgiltiAsujmL+QdGoxNyJ6fpSH4ANAW0W4DR99sDtYm557aw2pxZHYXjXLEXnzytIqPaNbaJxKX+4YAQXkzfcioDH7L5BCqJqDbdoXvH8QW31nhguT6sucZIY0SKE+1OvXcabI9Ht69jUwBSxMP6XT7g== 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=8xnCcy767WKevDP5UhHtnUI+xPQRl1REcs1nGDGtkcM=; b=a5Bl+gQGxqTGc3OsPvwVxdgpF4L+RAhPmeI3C9yKDSlQpzKYesknhCv727W1A4nhHAyLDyIpchHVjANA+CmBd03NtU+Gdfqr4nLTy2H1jVooVmZkpr5MCTK5IhfGGFXWWEorEA8MdL9d7n6+qhlc+KInF3yX35H0WiRcmMSdkSU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; Received: from DM6PR21MB1514.namprd21.prod.outlook.com (2603:10b6:5:22d::11) by DM5PR2101MB0981.namprd21.prod.outlook.com (2603:10b6:4:a8::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.4; Tue, 20 Jul 2021 14:57:27 +0000 Received: from DM6PR21MB1514.namprd21.prod.outlook.com ([fe80::3505:fa47:39d0:6dc5]) by DM6PR21MB1514.namprd21.prod.outlook.com ([fe80::3505:fa47:39d0:6dc5%9]) with mapi id 15.20.4373.005; Tue, 20 Jul 2021 14:57:27 +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, wei.liu@kernel.org, kys@microsoft.com, sthemmin@microsoft.com, ardb@kernel.org Cc: mikelley@microsoft.com Subject: [PATCH v11 5/5] Drivers: hv: Enable Hyper-V code to be built on ARM64 Date: Tue, 20 Jul 2021 07:57:03 -0700 Message-Id: <1626793023-13830-6-git-send-email-mikelley@microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1626793023-13830-1-git-send-email-mikelley@microsoft.com> References: <1626793023-13830-1-git-send-email-mikelley@microsoft.com> X-ClientProxiedBy: MWHPR07CA0023.namprd07.prod.outlook.com (2603:10b6:300:116::33) 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 (167.220.2.16) by MWHPR07CA0023.namprd07.prod.outlook.com (2603:10b6:300:116::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Tue, 20 Jul 2021 14:57:26 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 65c35511-5203-4c63-e5ba-08d94b8eb0b6 X-MS-TrafficTypeDiagnostic: DM5PR2101MB0981: 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:2733; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8WYNnTay10XxhQFaZJtKJDA/saIZGPWRlXz+sZxz++bOpf5IBlSPN3/wK26CAlGPn16jH5Mi+/2fjk761I6uffH4hHnFKHzWOhBPD8PvQTC/+qzxsgK9Bjd9FU0rPjlf8413UQmk/wQRPg9EJFO56YnBZ4aCcp5yJqtNK4egESZZw9a6zg3XzDrKwlp5J60YmpJPdOdvZO+GDmrx8HiKfPsd/0hMfc+xOrzoEv8gjrYhWm9+15y+VcvfYdP0NlVNtV+c8DB5p6gDqL9yvn9ssuGSJaPhhtkubXztLI+K7Is/rygpHKHJ2LFB/mYgJeMGR/Mix3fqnxqFO3fb/in2sVbodK+tvn9jtBZWR6lwlp8r6y8UNeztq8Wn4xwW7hgsFpLhS84VqIMrCG0V+8QXEzP/oDXjL1l+Em0I+mTB0v0T1CFIpCB9yXaVjMMB6wIRYn6hu3fraecl4MTjpHzL4x+h/fhgf9uwD1eEYvG54Cg/sXCrMg1z6Su49SJhw1NS9NrU8pWote6khHpQ2w5PN3EJqL0uQfGxHicO72TFqWOOtU+7NYVNvmJDSIP/+zXW5czO0AACskV/JW3MSys9bEbdcbBoFf5hX7KWe1oFO/ydBuaeGZerv33WlWwW6DJguv1W5EVOM50ucP+GUhVK3hkcieiB4bp94VKxln36IyjJruiQflsm1L8f54ly7G/aUYjBdVyOJ0qd6lfsz/P2P30VrzR6rAKvwsPyakiJ2x8= 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)(366004)(83380400001)(26005)(6666004)(36756003)(508600001)(956004)(10290500003)(66476007)(5660300002)(38350700002)(4326008)(8676002)(38100700002)(66946007)(2616005)(82950400001)(186003)(52116002)(7696005)(107886003)(6486002)(8936002)(82960400001)(4744005)(316002)(921005)(66556008)(86362001)(2906002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: EgWdLkqOs3gYep9WaAJK2KKde+oRAxsntMiDp0bDcK0KnI+e1liy88xDSnS1l6iI6jdHiZfJiY7LZhDCPybNfnTMR3Q82goclyi435sACmOxVQqjSfrPx7EDjA8XjedDBnNi9AL8DEnVvbmn9NLri+pWXe7XRztoRRQhsaXENKw0fXt96YB0zRwkCVHqC7k+7/UKyNPQqN6kD+q5k9yitJlpLKEbeWvSd3t+E9o6HWAtFjwOdw/jWaZL7tmDJUHqh44mFksVN8QN0UPTOH+ioeZDn2xo76ENQak5z+LfcQ6q8rcOpJX6weo1CjvU43e+eXHM4AYhApYslif9SiGN3vRUnjEBbWj6bI2ExSCqeIqMhEy71h8iufzDMVPIoGoiAkBnPjUs4qMl4mpZJREHyzpDzTNyPbP3nFc7Ad9E0DHzRHSX8B0tR+yPImxUMS9wA/pan2oDX75W40D8Py/zKikXPyMf7GtbEh4iEuZCnCqNcQ0bTCn5LhYVO4UWraACpW7lT23UAEpqhGWS6izkRfWNM7tyIfQrNNtKRWio8KVy8iUV/pTzdQkplbhweaHZL9RDz7AuldCepfbrFo1ghr1tDI69ePtM/ZQqm6E+3g+qSOUQvuEWTyU9K7hM+YfuXSqihr319KKVPDvTiLOqSFKCdGJbSoZxSX3jyucg/bBh7AP1sMT2aPfuZ9Mg0BDu5K66JSSDaLMJB7XU8Z/Y4cmE8FXEGMXtp9oPKR1rzW5HiNmFNj7NksNwK4+CQLtACUIWjlv0BYn0Kl25MIiCUMNq1DIj6svH2kJ9ww6G4X4fo0IzijJ4KGpNbzz1RnjjjQoT2oG9iAkEejr5Sf+StpmgpSCKTH7o2EkG42dNdLgH4OVGS+tp8cOc8M8b2Y8adfNjyFsVKpvrQKtMgUVUVkyAvoXz2t6be+GMy9Fz5odGdN82fSKJd9bY7Zlsm+LAakY0IlBG+Uz3cdjLA7n4Gc2RnYzEbyHjm36GSAzPJarXraWjkWgBU2B+vCgDhZl5sFG6lLNX1+e6SR4rOK4gw/PtC+pKHgFy89+bc0l7dS550x9iWgzFZ7SJEJDeD8h/9qq39EfGGLCazvedOWN8TXE0g79mUDS1MLa4RYTfyKLGKEpCnIf5jVEL+SBGTmC4Xe7Fchf1VEnBxXAhMsvpl6B1U0t79/e4miS6YUgvTGLuKv2w8EqxTcs4RRP3cA2lPjZCbD3Q/ZaI55OesOrEv5sGRsLCJwJdX22huFvKI2GEL9mbuj4JFF2wpGBF0/FKUWp3m1DfXYfMTMTkEWAFqpXdwg80MCRH5OnMdro9cB6yPErabwJzMhb0PkQY68aQ X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 65c35511-5203-4c63-e5ba-08d94b8eb0b6 X-MS-Exchange-CrossTenant-AuthSource: DM6PR21MB1514.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2021 14:57:27.3225 (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: ibMGh1hKM6nsGlMLWGvV3ZC2XBPNPJ9Ko7jO5xocHUwiO7lekaSQAqoHDKH2YfCBCxTQRXsPYGmrBlfzt2XotA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0981 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. Exclude the Hyper-V enlightened clocks/timers code from being built for ARM64. Signed-off-by: Michael Kelley Reviewed-by: Boqun Feng --- drivers/hv/Kconfig | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig index 66c794d..e509d5d 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 @@ -12,7 +13,7 @@ config HYPERV system. config HYPERV_TIMER - def_bool HYPERV + def_bool HYPERV && X86 config HYPERV_UTILS tristate "Microsoft Hyper-V Utilities driver"