From patchwork Wed Feb 1 17:43:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jintack Lim X-Patchwork-Id: 9550407 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 E5FEE60425 for ; Wed, 1 Feb 2017 17:44:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D80E02040D for ; Wed, 1 Feb 2017 17:44:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CAEC228435; Wed, 1 Feb 2017 17:44:39 +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.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable 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 56A532040D for ; Wed, 1 Feb 2017 17:44:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753188AbdBARod (ORCPT ); Wed, 1 Feb 2017 12:44:33 -0500 Received: from outprodmail01.cc.columbia.edu ([128.59.72.39]:34151 "EHLO outprodmail01.cc.columbia.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754049AbdBARna (ORCPT ); Wed, 1 Feb 2017 12:43:30 -0500 Received: from hazelnut (hazelnut.cc.columbia.edu [128.59.213.250]) by outprodmail01.cc.columbia.edu (8.14.4/8.14.4) with ESMTP id v11He8hv030677 for ; Wed, 1 Feb 2017 12:43:24 -0500 Received: from hazelnut (localhost.localdomain [127.0.0.1]) by hazelnut (Postfix) with ESMTP id A458383 for ; Wed, 1 Feb 2017 12:43:24 -0500 (EST) Received: from sendprodmail01.cc.columbia.edu (sendprodmail01.cc.columbia.edu [128.59.72.13]) by hazelnut (Postfix) with ESMTP id 833B183 for ; Wed, 1 Feb 2017 12:43:24 -0500 (EST) Received: from mail-qt0-f197.google.com (mail-qt0-f197.google.com [209.85.216.197]) by sendprodmail01.cc.columbia.edu (8.14.4/8.14.4) with ESMTP id v11HhOcL048229 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 1 Feb 2017 12:43:24 -0500 Received: by mail-qt0-f197.google.com with SMTP id g49so400249149qta.0 for ; Wed, 01 Feb 2017 09:43:24 -0800 (PST) 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=i6pQKMtKh7jGSkR0Tw0Eva0RIxtv0HiV0+KNlP++Q8I=; b=MdZlYlbpphnHVEb++9oO8rNudaWmoWmcOA46BVV1HC5B3lZm3L1HKrsNeamTCF4uDl p9nEIdWMdIkkhLR03ytgGuWgYawCPMFl8ydnYRKGcIVzrPTNXh8Cw42RV4NbdJ5Cvpjx aoiAsiDPaOuDQ0dNiXvCsZzPG2vJ748YEFawVcbEJKxJnu5jvuKNGN/USwiw2Jzsfl/u bZzrTIkt6OKMTeqgYmD3ERT8NzrtJdyfPT/BJAly9kl0OyIWAvfmCvjKkfu9FHvQk3k6 UC4F0TLH94+ErZasN9nKiQQpEx/C2mgzZ99zb4o/WCgOr8/UkIb5w8L223c1NUs+QA8f ZDBg== X-Gm-Message-State: AIkVDXIls3xMEbKblkf0EE+3PEYHJXMT+07yUzSbRbr90LnydMD+IE8YpekaLHYA+I1ZR3vbxDjej6lrEPmW2WkcZ44Ht4ktG4fsfVxByu5h/MsoqamHwicNar0w1qt5ijnjDj7QrGyC/JM= X-Received: by 10.55.20.17 with SMTP id e17mr3652018qkh.96.1485971003972; Wed, 01 Feb 2017 09:43:23 -0800 (PST) X-Received: by 10.55.20.17 with SMTP id e17mr3652000qkh.96.1485971003784; Wed, 01 Feb 2017 09:43:23 -0800 (PST) Received: from jintack.cs.columbia.edu ([2001:18d8:ffff:16:21a:4aff:feaa:f900]) by smtp.gmail.com with ESMTPSA id b16sm19149046qka.9.2017.02.01.09.43.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Feb 2017 09:43:22 -0800 (PST) From: Jintack Lim To: pbonzini@redhat.com, rkrcmar@redhat.com, christoffer.dall@linaro.org, marc.zyngier@arm.com, linux@armlinux.org.uk, catalin.marinas@arm.com, will.deacon@arm.com, andre.przywara@arm.com, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org Cc: jintack@cs.columbia.edu Subject: [RFC v3 09/10] KVM: arm64: Add the EL1 physical timer access handler Date: Wed, 1 Feb 2017 12:43:09 -0500 Message-Id: <1485970990-13775-10-git-send-email-jintack@cs.columbia.edu> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1485970990-13775-1-git-send-email-jintack@cs.columbia.edu> References: <1485970990-13775-1-git-send-email-jintack@cs.columbia.edu> X-No-Spam-Score: Local X-Scanned-By: MIMEDefang 2.78 on 128.59.72.13 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP KVM traps on the EL1 phys timer accesses from VMs, but it doesn't handle those traps. This results in terminating VMs. Instead, set a handler for the EL1 phys timer access, and inject an undefined exception as an intermediate step. Signed-off-by: Jintack Lim Reviewed-by: Christoffer Dall --- arch/arm64/kvm/sys_regs.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index caa47ce..1cd3464 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -820,6 +820,30 @@ static bool access_pmuserenr(struct kvm_vcpu *vcpu, struct sys_reg_params *p, CRm((0b1100 | (((n) >> 3) & 0x3))), Op2(((n) & 0x7)), \ access_pmu_evtyper, reset_unknown, (PMEVTYPER0_EL0 + n), } +static bool access_cntp_tval(struct kvm_vcpu *vcpu, + struct sys_reg_params *p, + const struct sys_reg_desc *r) +{ + kvm_inject_undefined(vcpu); + return true; +} + +static bool access_cntp_ctl(struct kvm_vcpu *vcpu, + struct sys_reg_params *p, + const struct sys_reg_desc *r) +{ + kvm_inject_undefined(vcpu); + return true; +} + +static bool access_cntp_cval(struct kvm_vcpu *vcpu, + struct sys_reg_params *p, + const struct sys_reg_desc *r) +{ + kvm_inject_undefined(vcpu); + return true; +} + /* * Architected system registers. * Important: Must be sorted ascending by Op0, Op1, CRn, CRm, Op2 @@ -1029,6 +1053,16 @@ static bool access_pmuserenr(struct kvm_vcpu *vcpu, struct sys_reg_params *p, { Op0(0b11), Op1(0b011), CRn(0b1101), CRm(0b0000), Op2(0b011), NULL, reset_unknown, TPIDRRO_EL0 }, + /* CNTP_TVAL_EL0 */ + { Op0(0b11), Op1(0b011), CRn(0b1110), CRm(0b0010), Op2(0b000), + access_cntp_tval }, + /* CNTP_CTL_EL0 */ + { Op0(0b11), Op1(0b011), CRn(0b1110), CRm(0b0010), Op2(0b001), + access_cntp_ctl }, + /* CNTP_CVAL_EL0 */ + { Op0(0b11), Op1(0b011), CRn(0b1110), CRm(0b0010), Op2(0b010), + access_cntp_cval }, + /* PMEVCNTRn_EL0 */ PMU_PMEVCNTR_EL0(0), PMU_PMEVCNTR_EL0(1),