From patchwork Tue Aug 6 20:31:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael Kelley (LINUX)" X-Patchwork-Id: 11079613 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8AA60112C for ; Tue, 6 Aug 2019 20:32:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 79E52288D0 for ; Tue, 6 Aug 2019 20:32:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6DE8F288F6; Tue, 6 Aug 2019 20:32:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E6CA4288EE for ; Tue, 6 Aug 2019 20:32:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=FGD10QrmPDFoOquxCZR6vFzeLhCBed4c/SBWhkKYUNQ=; b=O7VGzkiTa6b4pM 1aJdLHymH0+bOdjyD1gFuN4VymVGNGgMI1wQE3sqM1ly8sLP/f3zIRH97304NNsROuycN/HBzREbW RXrjT/hREpmyo4xlwfALruZEKGoGCepR2gpvmvx8JJQq7ca8qw4o+alwxeqRWVSVnVzFMpO9JbFZF CyQcuZ8qydw3NfZZNvNcBTSt/giJqAA4cXxRpuI8hcvu5VsP6CkFcfRsfFokSCXcFmipEGrtZsVUM nQU7v2LEMvGgoTUHG528axhy/iU4HhPUS++Br8MrV2IY3J5gUqlUCKwQAy5WouYTPdokzUaPVzK/Y SXTH8xKdlp7zBrRtkedA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hv68L-00079t-7Y; Tue, 06 Aug 2019 20:32:37 +0000 Received: from mail-eopbgr820111.outbound.protection.outlook.com ([40.107.82.111] helo=NAM01-SN1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hv66w-0005kG-Kw for linux-arm-kernel@lists.infradead.org; Tue, 06 Aug 2019 20:31:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d5OiMmyZFl71fxWZiiAEC995k9jThY+EXeDqQBKU7QKjw/k0EjLc+iHB92s0E5nStPLDLZRBJr3qjph5APKgQ6k4XOa1QwB4EXMMw+M9q6ZpkeMga5MXaNjClwOHLT9pN+A9gpOdbQq5SyAvW8ztgw2Hspq5LG7vaBg2urJdPedKxiCKfuGS3xo36XW5Rluy2VXUwsMoE13I8x4abrTPBOhCRucuJQaMdNpUuDsN7R2wsYOieLL7X63U0pqxs2dGFHf/j86BoBXxWqtQr6MonbtKYe28p3K12i1BFSLAwggQkNBLIqbdmkwG1yG/B+0pccRBpVEAfUWxFas0If7kaQ== 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=PJ4JKZIyEkt+ZqlOZNewTe208jaLwJVudybMI898C8A=; b=Zm8H87C3RKO5/u8+lPreosWTQjUgzYfOTTTbJ4TFlmcoZp3z+25F6vkFUJ/8HCfrFQ5K4NbtxC1nET5XWPPcF+W7TZsoxhp0eB72eMwiHliXXzxS5eGh2pPSl/IMNZxWparjrUmBE4SD8KmcVagODsmisSEGW2WxNntTIqMMf8xnYLdZjU//3uWec+5t8LiErpzqD8KEwgZrk5nxzVoVdNuf1RwqGXHnOEZbssT4kQ7f36EV3erTF2DDOWb2ReIhWvqrrBSvsB1GrTzbOppPaJqp3SJ5HkAfby/ecMJi5N3J2u2I647w24VH4JfsGr4Kn4om3hrDYKMRVb9seSkuqw== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PJ4JKZIyEkt+ZqlOZNewTe208jaLwJVudybMI898C8A=; b=kUgaWYOa9MTKrC6sX+HuVdHXO6cA8tJZIso8tFQiMPN/VB5b7S0IE/RgLMw22ZNoQcCRxzQpobzXiZKzmFsnLbTBTAtvh/Ab+Fuushd88+ScI/Ub3Y2mRd9YwZ4AnLgokwFjrq01XTK16I3lf/NQ3NuTfDjUdt7R//TCexToOOo= Received: from BYAPR21MB1335.namprd21.prod.outlook.com (20.179.60.209) by BYAPR21MB1255.namprd21.prod.outlook.com (20.179.57.159) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2157.9; Tue, 6 Aug 2019 20:31:06 +0000 Received: from BYAPR21MB1335.namprd21.prod.outlook.com ([fe80::819:aea0:eda4:9301]) by BYAPR21MB1335.namprd21.prod.outlook.com ([fe80::819:aea0:eda4:9301%9]) with mapi id 15.20.2157.001; Tue, 6 Aug 2019 20:31:06 +0000 From: Michael Kelley To: "will.deacon@arm.com" , "catalin.marinas@arm.com" , "mark.rutland@arm.com" , "marc.zyngier@arm.com" , "linux-arm-kernel@lists.infradead.org" , "gregkh@linuxfoundation.org" , "linux-kernel@vger.kernel.org" , "linux-hyperv@vger.kernel.org" , "devel@linuxdriverproject.org" , "olaf@aepfle.de" , "apw@canonical.com" , vkuznets , "jasowang@redhat.com" , "marcelo.cerri@canonical.com" , KY Srinivasan Subject: [PATCH v4 5/8] arm64: hyperv: Add kexec and panic handlers Thread-Topic: [PATCH v4 5/8] arm64: hyperv: Add kexec and panic handlers Thread-Index: AQHVTJXfLSWJuU36KkieVE028kSu1Q== Date: Tue, 6 Aug 2019 20:31:06 +0000 Message-ID: <1565122133-9086-6-git-send-email-mikelley@microsoft.com> References: <1565122133-9086-1-git-send-email-mikelley@microsoft.com> In-Reply-To: <1565122133-9086-1-git-send-email-mikelley@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: MWHPR01CA0030.prod.exchangelabs.com (2603:10b6:300:101::16) To BYAPR21MB1335.namprd21.prod.outlook.com (2603:10b6:a03:115::17) authentication-results: spf=none (sender IP is ) smtp.mailfrom=mikelley@microsoft.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 1.8.3.1 x-originating-ip: [131.107.174.8] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 254d8428-1ebc-4fca-9d8b-08d71aad0200 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:BYAPR21MB1255; x-ms-traffictypediagnostic: BYAPR21MB1255:|BYAPR21MB1255: 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-forefront-prvs: 0121F24F22 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(4636009)(366004)(39860400002)(396003)(376002)(136003)(346002)(189003)(199004)(71200400001)(102836004)(71190400001)(386003)(6636002)(6512007)(66446008)(7416002)(10090500001)(6506007)(10290500003)(66946007)(316002)(50226002)(110136005)(14454004)(4326008)(6116002)(1511001)(52116002)(64756008)(99286004)(2501003)(2201001)(25786009)(68736007)(476003)(11346002)(446003)(86362001)(8936002)(3846002)(486006)(6486002)(256004)(8676002)(54906003)(76176011)(26005)(4720700003)(186003)(7736002)(81166006)(81156014)(2616005)(66066001)(66476007)(22452003)(5660300002)(2906002)(53936002)(305945005)(478600001)(6436002)(36756003)(66556008)(921003)(1121003); DIR:OUT; SFP:1102; SCL:1; SRVR:BYAPR21MB1255; H:BYAPR21MB1335.namprd21.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 1nzbvI+QD6rW7PZhvXLe9NRgGAu6yaksfefYnIk20wfEgZTG4E77Mt8cmdNOfEx/NiaSIxcLT4JjA6Hsx24B/U8Ez/8L+4LArQCcb1HLmuL3wS2by+S4N1nRyyG6/t8RXs+GMeBZztdyH0E9uWYeNrVP7JBr1no7THze+BVe/yftmoEu6BVTLPn+SeMdatbANBjbCWeiXH8vyQkcdnKw+HgXcxYRvsvsCuQCl5YRQcq0Mtv99b/2PZzPz8kPKv0ty+sbYXUBbGRuHtgNHzP+6+qaEWUySsPvphENFMsdfEfvwDkJrPVa/wr3zyk+Wm39VEHcFHDHs5LTnuiMc1M+fl/Z3bCZa+gZuO1wRZj1ifpHwyvNBAf0ruABoCd7sIh+fcwE1bxk0UfmKjV2/yzehcQkYmkxuSmnc3XCqV64RA0= MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 254d8428-1ebc-4fca-9d8b-08d71aad0200 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Aug 2019 20:31:06.2957 (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: gMeyABJJ1P8PGxXALb49e5mdiJB8FZLFCeU+FpllfeX4efYh7M90BnQRb5TPFsoMlXXAuzRZ87QeS9FAHlweUA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR21MB1255 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190806_133110_777515_61AF74AF X-CRM114-Status: GOOD ( 13.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sunil Muthuswamy , "boqun.feng" , Michael Kelley Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add functions to set up and remove kexec and panic handlers, and to inform Hyper-V about a guest panic. These functions 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/hv_init.c | 61 ++++++++++++++++++++++++++++++++++++++++++++ arch/arm64/hyperv/mshyperv.c | 26 +++++++++++++++++++ 2 files changed, 87 insertions(+) diff --git a/arch/arm64/hyperv/hv_init.c b/arch/arm64/hyperv/hv_init.c index 9c294f6..67350ec 100644 --- a/arch/arm64/hyperv/hv_init.c +++ b/arch/arm64/hyperv/hv_init.c @@ -199,3 +199,64 @@ void hv_get_vpreg_128(u32 msr, struct hv_get_vp_register_output *result) } EXPORT_SYMBOL_GPL(hv_get_vpreg_128); + +void hyperv_report_panic(struct pt_regs *regs, long err) +{ + static bool panic_reported; + u64 guest_id; + + /* + * 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'. + */ + 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); + +/* + * hyperv_report_panic_msg - report panic message to Hyper-V + * @pa: physical address of the panic page containing the message + * @size: size of the message in the page + */ +void hyperv_report_panic_msg(phys_addr_t pa, size_t size) +{ + /* + * P3 to contain the physical address of the panic page & P4 to + * contain the size of the panic data in that page. Rest of the + * registers are no-op when the NOTIFY_MSG flag is set. + */ + hv_set_vpreg(HV_REGISTER_CRASH_P0, 0); + hv_set_vpreg(HV_REGISTER_CRASH_P1, 0); + hv_set_vpreg(HV_REGISTER_CRASH_P2, 0); + hv_set_vpreg(HV_REGISTER_CRASH_P3, pa); + hv_set_vpreg(HV_REGISTER_CRASH_P4, size); + + /* + * Let Hyper-V know there is crash data available along with + * the panic message. + */ + hv_set_vpreg(HV_REGISTER_CRASH_CTL, + (HV_CRASH_CTL_CRASH_NOTIFY | HV_CRASH_CTL_CRASH_NOTIFY_MSG)); +} +EXPORT_SYMBOL_GPL(hyperv_report_panic_msg); diff --git a/arch/arm64/hyperv/mshyperv.c b/arch/arm64/hyperv/mshyperv.c index ae6ece6..c58940d 100644 --- a/arch/arm64/hyperv/mshyperv.c +++ b/arch/arm64/hyperv/mshyperv.c @@ -23,6 +23,8 @@ static void (*vmbus_handler)(void); static void (*hv_stimer0_handler)(void); +static void (*hv_kexec_handler)(void); +static void (*hv_crash_handler)(struct pt_regs *regs); static int vmbus_irq; static long __percpu *vmbus_evt; @@ -137,3 +139,27 @@ void hv_remove_stimer0_irq(int irq) } } EXPORT_SYMBOL_GPL(hv_remove_stimer0_irq); + +void hv_setup_kexec_handler(void (*handler)(void)) +{ + hv_kexec_handler = handler; +} +EXPORT_SYMBOL_GPL(hv_setup_kexec_handler); + +void hv_remove_kexec_handler(void) +{ + hv_kexec_handler = NULL; +} +EXPORT_SYMBOL_GPL(hv_remove_kexec_handler); + +void hv_setup_crash_handler(void (*handler)(struct pt_regs *regs)) +{ + hv_crash_handler = handler; +} +EXPORT_SYMBOL_GPL(hv_setup_crash_handler); + +void hv_remove_crash_handler(void) +{ + hv_crash_handler = NULL; +} +EXPORT_SYMBOL_GPL(hv_remove_crash_handler);