From patchwork Tue Aug 26 12:49:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 36015 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f197.google.com (mail-ob0-f197.google.com [209.85.214.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A3B532054F for ; Tue, 26 Aug 2014 12:51:45 +0000 (UTC) Received: by mail-ob0-f197.google.com with SMTP id vb8sf85102256obc.8 for ; Tue, 26 Aug 2014 05:51:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id:cc :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=VhFPXedMm7+iaa+Bfa7bzscSs6w2EmrzP5Aq/tE0zts=; b=hQe+U4UyturXq3a2UaUklPsPw/J5NrGQyRv6apQNzyXUAO5pf10w+5k0Rp5YqmebxY aOx6U4FY6QDxcCb9axn+HiTmcHUhJq4AS+xgrqn9B4F0ARlL2PZt1lbH6jFaN86H7+rX 05voed46xrhguSwZ9RDyYc+s5pz8EF3IZhtCzHRv4Nbof6w36FBBmHGWTGxc1MxVgAaN kNQSRq8vnR3xCm51RpV7V/AYLopKjFQnRgbCTEbOarJx/O3TesM6D54fCl9BVX7gt1Ju aJ/44O0C1AoP3IbdfkTz+8PjDUgBTARLFIGANJJ29YXYwrVTuBLGQbbfJGR3vExJLrQJ na7A== X-Gm-Message-State: ALoCoQmQnUDFNtHjlKE7Xx+yz8UiK4hMWgZr+ebF1uODM7+n/1ldFWNRTzoM/t7FwDy6Nj+QUQt0 X-Received: by 10.182.28.102 with SMTP id a6mr18741286obh.44.1409057505254; Tue, 26 Aug 2014 05:51:45 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.23.69 with SMTP id 63ls2317243qgo.59.gmail; Tue, 26 Aug 2014 05:51:45 -0700 (PDT) X-Received: by 10.52.32.230 with SMTP id m6mr130988vdi.74.1409057505087; Tue, 26 Aug 2014 05:51:45 -0700 (PDT) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id o4si1301225vcy.87.2014.08.26.05.51.45 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 26 Aug 2014 05:51:45 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id la4so16503440vcb.23 for ; Tue, 26 Aug 2014 05:51:45 -0700 (PDT) X-Received: by 10.220.97.5 with SMTP id j5mr23774733vcn.16.1409057504973; Tue, 26 Aug 2014 05:51:44 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.45.67 with SMTP id uj3csp196196vcb; Tue, 26 Aug 2014 05:51:44 -0700 (PDT) X-Received: by 10.69.25.35 with SMTP id in3mr37287069pbd.63.1409057503921; Tue, 26 Aug 2014 05:51:43 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id i1si4006741pdf.193.2014.08.26.05.51.43 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Aug 2014 05:51:43 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XMGCi-0003bb-VH; Tue, 26 Aug 2014 12:50:28 +0000 Received: from mail-la0-f42.google.com ([209.85.215.42]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XMGCe-0002Gd-Ui for linux-arm-kernel@lists.infradead.org; Tue, 26 Aug 2014 12:50:26 +0000 Received: by mail-la0-f42.google.com with SMTP id pv20so15003539lab.1 for ; Tue, 26 Aug 2014 05:50:01 -0700 (PDT) X-Received: by 10.152.28.67 with SMTP id z3mr28309551lag.12.1409057401036; Tue, 26 Aug 2014 05:50:01 -0700 (PDT) Received: from localhost.localdomain (188-178-240-98-static.dk.customer.tdc.net. [188.178.240.98]) by mx.google.com with ESMTPSA id ls6sm2020705lac.2.2014.08.26.05.49.59 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 26 Aug 2014 05:50:00 -0700 (PDT) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu Subject: [PATCH] arm/arm64: KVM: Complete WFI/WFE instructions Date: Tue, 26 Aug 2014 14:49:47 +0200 Message-Id: <1409057387-27458-1-git-send-email-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.0.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140826_055025_183761_B77AB193 X-CRM114-Status: GOOD ( 15.37 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.215.42 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.215.42 listed in wl.mailspike.net] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: Christoffer Dall , Marc Zyngier , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Ard Biesheuvel X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: christoffer.dall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 The architecture specifies that when the processor wakes up from a WFE or WFI instruction, the instruction is considered complete, however we currrently return to EL1 (or EL0) at the WFI/WFE instruction itself. While most guests may not be affected by this because their local exception handler performs an exception returning setting the event bit or with an interrupt pending, some guests like UEFI will get wedged due this little mishap. Simply skip the instruction when we have completed the emulation. Cc: Marc Zyngier Cc: Ard Biesheuvel Signed-off-by: Christoffer Dall --- Note that I haven't confirmed exactly how Linux guests survives WFI without this fix. My working hypothesis is that the Linux ISR doesn't complete the interrupt, leaving an active interrupt on the LR, which may cause the PE to consider it a wake-up event for the WFI despite the EL1 handler returning to the WFI instruction itself. Tianocore on the other hand may complete the interrupt entirely before returning to the WFI instruction. Input on this is most welcome and likely to improve the quality of my sleep. arch/arm/kvm/handle_exit.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm/kvm/handle_exit.c b/arch/arm/kvm/handle_exit.c index 4c979d4..a96a804 100644 --- a/arch/arm/kvm/handle_exit.c +++ b/arch/arm/kvm/handle_exit.c @@ -93,6 +93,8 @@ static int kvm_handle_wfx(struct kvm_vcpu *vcpu, struct kvm_run *run) else kvm_vcpu_block(vcpu); + kvm_skip_instr(vcpu, kvm_vcpu_trap_il_is32bit(vcpu)); + return 1; }