From patchwork Tue Oct 3 03:10:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jintack Lim X-Patchwork-Id: 9981537 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 90CB4602B8 for ; Tue, 3 Oct 2017 03:16:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 837162887F for ; Tue, 3 Oct 2017 03:16:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7853D28882; Tue, 3 Oct 2017 03:16:31 +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=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 278402887F for ; Tue, 3 Oct 2017 03:16:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751817AbdJCDQ2 (ORCPT ); Mon, 2 Oct 2017 23:16:28 -0400 Received: from mail-it0-f43.google.com ([209.85.214.43]:45082 "EHLO mail-it0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751943AbdJCDL5 (ORCPT ); Mon, 2 Oct 2017 23:11:57 -0400 Received: by mail-it0-f43.google.com with SMTP id x15so9995896itb.0 for ; Mon, 02 Oct 2017 20:11:56 -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=IE1+KtTIoDmOucQNOfpWKkMpUSrr3a1flJWEXmYlv7A=; b=JNR54jLEre4doOf/x4DNDnjdNDNVkiNSdmb1opHW7oBmQoyPV4hU6hEIYIyazhhecg kFHVNURF7yM/VHIaUFCewDGHi8O2cyHiQIbvQ51BupnPkLhN2Ezt8SoyW1uoYvPkgWxI JZlfaBblWzBxZ4m4t5HTS8ff9HjlZplNfRbiU= 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=IE1+KtTIoDmOucQNOfpWKkMpUSrr3a1flJWEXmYlv7A=; b=iUrHFV3kRbfafGn4fBjRx2Oebt2meaISPi/E4GUwXtdpybTcS1hGgINNz4PJ60iKDV QxvngL+i8sm48UjpHXAaUvXoaUtjeZhgtbyJPsz7/34sG0uoZ5azaxs3i0+EVpIvEiOs IZy4SEXBzJxNpYeSNW3vUjcYZvhS192CRgbxCEKBMtttifhF15ZYwOfO+2YeC+mvg+5K MRh7W59gmY/GS/9Sb+8DE9jrVyrRFK8TSebaKhliZXwrwOUNLL6jD45Op2aluTfqKUtU 2onIw97pdji5evisfMXV3IZnepE6qXn1Y5LpphhNPBNw9Jwv14dNK12f71D0X9SscU5+ 99dQ== X-Gm-Message-State: AMCzsaW1DrAt1f+o4jDm+K7okgB6upSco/POpF7VTrrQcYYtOajcxZ95 K2Of9ah0787oYbI4r4gQ8zmCyQ== X-Google-Smtp-Source: AOwi7QBrbCe27FQHIJxISLpYWiv/xdugJGOt8/2uSlWCBVo50vFp0kTywQutboVDDR6pRY+ug7qiZQ== X-Received: by 10.36.206.65 with SMTP id v62mr11047002itg.104.1507000316352; Mon, 02 Oct 2017 20:11:56 -0700 (PDT) Received: from node.jintackl-qv28633.kvmarm-pg0.wisc.cloudlab.us (c220g1-031126.wisc.cloudlab.us. [128.104.222.76]) by smtp.gmail.com with ESMTPSA id h84sm5367193iod.72.2017.10.02.20.11.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 02 Oct 2017 20:11:55 -0700 (PDT) From: Jintack Lim To: christoffer.dall@linaro.org, marc.zyngier@arm.com, kvmarm@lists.cs.columbia.edu Cc: jintack@cs.columbia.edu, pbonzini@redhat.com, rkrcmar@redhat.com, catalin.marinas@arm.com, will.deacon@arm.com, linux@armlinux.org.uk, mark.rutland@arm.com, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Jintack Lim Subject: [RFC PATCH v2 16/31] KVM: arm64: Introduce sys_reg_desc.forward_trap Date: Mon, 2 Oct 2017 22:10:58 -0500 Message-Id: <1507000273-3735-14-git-send-email-jintack.lim@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1507000273-3735-1-git-send-email-jintack.lim@linaro.org> References: <1507000273-3735-1-git-send-email-jintack.lim@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 This introduces a function prototype to determine if we need to forward system instruction traps to the virtual EL2. The implementation of forward_trap functions for each system instruction will be added in later patches. Signed-off-by: Jintack Lim --- arch/arm64/kvm/sys_regs.c | 8 ++++++++ arch/arm64/kvm/sys_regs.h | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index 541bb97..88ce172 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -1661,6 +1661,14 @@ static void perform_access(struct kvm_vcpu *vcpu, */ BUG_ON(!r->access); + /* + * Forward this trap to the virtual EL2 if the guest hypervisor has + * configured to trap the current instruction. + */ + if (nested_virt_in_use(vcpu) && r->forward_trap + && unlikely(r->forward_trap(vcpu))) + return; + /* Skip instruction if instructed so */ if (likely(r->access(vcpu, params, r))) kvm_skip_instr(vcpu, kvm_vcpu_trap_il_is32bit(vcpu)); diff --git a/arch/arm64/kvm/sys_regs.h b/arch/arm64/kvm/sys_regs.h index 827717b..6dd4008 100644 --- a/arch/arm64/kvm/sys_regs.h +++ b/arch/arm64/kvm/sys_regs.h @@ -61,6 +61,12 @@ struct sys_reg_desc { const struct kvm_one_reg *reg, void __user *uaddr); int (*set_user)(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, const struct kvm_one_reg *reg, void __user *uaddr); + + /* + * Forward the trap to the virtual EL2 if the guest hypervisor has + * configured to trap the current instruction. + */ + bool (*forward_trap)(struct kvm_vcpu *vcpu); }; static inline void print_sys_reg_instr(const struct sys_reg_params *p)