From patchwork Sun Apr 23 17:08:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 9694975 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 16F4860245 for ; Sun, 23 Apr 2017 17:11:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F415426530 for ; Sun, 23 Apr 2017 17:11:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E8C14265B9; Sun, 23 Apr 2017 17:11:46 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9109C26530 for ; Sun, 23 Apr 2017 17:11:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1163234AbdDWRLp (ORCPT ); Sun, 23 Apr 2017 13:11:45 -0400 Received: from mail-wm0-f52.google.com ([74.125.82.52]:36711 "EHLO mail-wm0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1162686AbdDWRKQ (ORCPT ); Sun, 23 Apr 2017 13:10:16 -0400 Received: by mail-wm0-f52.google.com with SMTP id u65so7505040wmu.1 for ; Sun, 23 Apr 2017 10:10:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Q0yLbT6pWsCIjdeTvoIh9zq6j8OdA9H9z5xEsozjG8c=; b=iqo6pnOx0s6jhvl/vM+yilT9z4HWedz+TZAevuS+0V09h74CY2o3j0FB9s1Icl1MgT PCnC0LKXlb0q9kMzosHQyUNi1noC8M21xCxRKAD2tuMLvJhGOg0l5y4UjSppnEJ0KsVT MY9cafzQDYWbiZ/1RzD4P2NgdEPh6XB5Clcag= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Q0yLbT6pWsCIjdeTvoIh9zq6j8OdA9H9z5xEsozjG8c=; b=QlR+aY3YZqRsPX7TdGae7a8uSPNfSQCsOGRX0b/ka9LGToV/uFhhOSUBdUYnJchH9s YOGe4k5b21j/0qYHnBXwGaBdnl+1hQr9ARHJpHoRJhuRPdpFIl/6b5fMrX3+gIAV0oBg KiM4UKyGTyEdV8yTzPEZOJPHFb6eFXQbI6aZsK+YAwL1UA7BgyZvC/ZdcJSsMmTUq0+f IuD+azd+INj0GO9EoZYcqFXiEG+G+D8DfME5W86kmIKOkEvfInxmaKkNHNaHTF4Wf5iu 6HL1F0y+gxG7H9w8rPFLAbRxUhqy2z11TysaDKUDGtODqJzf1GfrLT84Dr7hUk2AwCBc hKhg== X-Gm-Message-State: AN3rC/5uOVkslKlk6+DIDG+pCzzJwpzd+7iSPaIooDPmUcGqVoZnvPx6 Dee2tjEYF8HVL69v X-Received: by 10.80.183.146 with SMTP id h18mr132491ede.39.1492967414449; Sun, 23 Apr 2017 10:10:14 -0700 (PDT) Received: from localhost.localdomain (xd93ddc2d.cust.hiper.dk. [217.61.220.45]) by smtp.gmail.com with ESMTPSA id 58sm2803521edz.2.2017.04.23.10.10.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 23 Apr 2017 10:10:13 -0700 (PDT) From: Christoffer Dall To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Cc: Marc Zyngier , kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Christoffer Dall Subject: [PULL 41/79] arm64: hyp-stub: Implement HVC_RESET_VECTORS stub hypercall Date: Sun, 23 Apr 2017 19:08:51 +0200 Message-Id: <20170423170929.27334-42-cdall@linaro.org> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170423170929.27334-1-cdall@linaro.org> References: <20170423170929.27334-1-cdall@linaro.org> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Marc Zyngier Let's define a new stub hypercall that resets the HYP configuration to its default: hyp-stub vectors, and MMU disabled. Of course, for the hyp-stub itself, this is a trivial no-op. Hypervisors will have a bit more work to do. Acked-by: Catalin Marinas Reviewed-by: James Morse Signed-off-by: Marc Zyngier Signed-off-by: Christoffer Dall --- arch/arm64/include/asm/virt.h | 9 +++++++++ arch/arm64/kernel/hyp-stub.S | 11 ++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/virt.h b/arch/arm64/include/asm/virt.h index 1569c3a..435514c 100644 --- a/arch/arm64/include/asm/virt.h +++ b/arch/arm64/include/asm/virt.h @@ -44,6 +44,14 @@ */ #define HVC_SOFT_RESTART 2 +/* + * HVC_RESET_VECTORS - Restore the vectors to the original HYP stubs + */ +#define HVC_RESET_VECTORS 3 + +/* Max number of HYP stub hypercalls */ +#define HVC_STUB_HCALL_NR 4 + /* Error returned when an invalid stub number is passed into x0 */ #define HVC_STUB_ERR 0xbadca11 @@ -70,6 +78,7 @@ extern u32 __boot_cpu_mode[2]; void __hyp_set_vectors(phys_addr_t phys_vector_base); phys_addr_t __hyp_get_vectors(void); +void __hyp_reset_vectors(void); /* Reports the availability of HYP mode */ static inline bool is_hyp_mode_available(void) diff --git a/arch/arm64/kernel/hyp-stub.S b/arch/arm64/kernel/hyp-stub.S index f53e8b8..8226fd9 100644 --- a/arch/arm64/kernel/hyp-stub.S +++ b/arch/arm64/kernel/hyp-stub.S @@ -73,8 +73,11 @@ el1_sync: mov x1, x3 br x4 // no return +3: cmp x0, #HVC_RESET_VECTORS + beq 9f // Nothing to reset! + /* Someone called kvm_call_hyp() against the hyp-stub... */ -3: ldr x0, =HVC_STUB_ERR + ldr x0, =HVC_STUB_ERR 9: eret ENDPROC(el1_sync) @@ -127,3 +130,9 @@ ENTRY(__hyp_set_vectors) hvc #0 ret ENDPROC(__hyp_set_vectors) + +ENTRY(__hyp_reset_vectors) + mov x0, #HVC_RESET_VECTORS + hvc #0 + ret +ENDPROC(__hyp_reset_vectors)