From patchwork Tue Aug 26 13:21:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 36025 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f71.google.com (mail-pa0-f71.google.com [209.85.220.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9494220551 for ; Tue, 26 Aug 2014 13:24:28 +0000 (UTC) Received: by mail-pa0-f71.google.com with SMTP id et14sf123502608pad.6 for ; Tue, 26 Aug 2014 06:24:27 -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=VfsVTLcxwUwZT5SZhkK6MrqGTLYbmOxJPFGXOq31tBg=; b=FpAwIgqVwJ1NJhPTIIxu7ozNtEGhIjV7DEfBPcfzp7tGTx0JuqxrZUyEhz80n5PwBS bUwhINwlbigu7TqpWidSFDvLABWOyBSfhupDInBISOnGEK4xYk7/urMFHvGdnn6W/O+k JdwSoyoBW6alMvqpP1MFDfrPm3PXSRge4gik6Et0r3QlGy09I8G+Fbv5P0JHlvZCzj9F jB7XcSS72aBe6rmFfJSNcQ1YR3uptQOmHWH7JbdrvLkIWZJc/G22uP9s8qhsXILTY5t6 9LEgCoFEPma60TDtTmGfnNFCKHQdwr6vGp5tIMEmso4DYqSc64EnSu1kNYroozXLKEhC HoCw== X-Gm-Message-State: ALoCoQk0yRSz4lpLQbLGWxq+QDeJYOfrJp/wVKLezd50oMw4S3DgSMNgEjSB1xrL46OJAfiEIXwF X-Received: by 10.66.218.162 with SMTP id ph2mr18166243pac.3.1409059466903; Tue, 26 Aug 2014 06:24:26 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.23.69 with SMTP id 63ls2346603qgo.59.gmail; Tue, 26 Aug 2014 06:24:26 -0700 (PDT) X-Received: by 10.52.121.74 with SMTP id li10mr20053564vdb.19.1409059466612; Tue, 26 Aug 2014 06:24:26 -0700 (PDT) Received: from mail-vc0-f172.google.com (mail-vc0-f172.google.com [209.85.220.172]) by mx.google.com with ESMTPS id o8si1413141vda.105.2014.08.26.06.24.26 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 26 Aug 2014 06:24:26 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.172 as permitted sender) client-ip=209.85.220.172; Received: by mail-vc0-f172.google.com with SMTP id im17so16953624vcb.3 for ; Tue, 26 Aug 2014 06:24:26 -0700 (PDT) X-Received: by 10.52.120.51 with SMTP id kz19mr199269vdb.95.1409059466484; Tue, 26 Aug 2014 06:24:26 -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 uj3csp198774vcb; Tue, 26 Aug 2014 06:24:25 -0700 (PDT) X-Received: by 10.69.26.68 with SMTP id iw4mr19618476pbd.137.1409059465225; Tue, 26 Aug 2014 06:24:25 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [198.137.202.9]) by mx.google.com with ESMTPS id bz6si4339632pdb.149.2014.08.26.06.24.24 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Aug 2014 06:24:25 -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=198.137.202.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 1XMGhY-00045S-VO; Tue, 26 Aug 2014 13:22:20 +0000 Received: from mail-lb0-f182.google.com ([209.85.217.182]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XMGhV-0003rD-30 for linux-arm-kernel@lists.infradead.org; Tue, 26 Aug 2014 13:22:19 +0000 Received: by mail-lb0-f182.google.com with SMTP id n15so1360877lbi.27 for ; Tue, 26 Aug 2014 06:21:54 -0700 (PDT) X-Received: by 10.152.245.171 with SMTP id xp11mr28052494lac.61.1409059314270; Tue, 26 Aug 2014 06:21:54 -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 rl10sm2051867lac.28.2014.08.26.06.21.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 26 Aug 2014 06:21:53 -0700 (PDT) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu Subject: [PATCH v2] arm/arm64: KVM: Complete WFI/WFE instructions Date: Tue, 26 Aug 2014 15:21:51 +0200 Message-Id: <1409059311-31452-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_062217_316247_3ADFF7AC X-CRM114-Status: GOOD ( 11.34 ) 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.217.182 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.217.182 listed in wl.mailspike.net] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: Christoffer Dall , 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.172 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 Linux guests may not be affected by this because their local exception handler performs an exception returning setting the event bit and has a separate context for the idle thread calling WFI, some guests like UEFI will get wedged due this little mishap. Simply skip the instruction when we have completed the emulation. Cc: Ard Biesheuvel Signed-off-by: Christoffer Dall --- Changes [v2]: - Also fix this for arm64 arch/arm/kvm/handle_exit.c | 2 ++ arch/arm64/kvm/handle_exit.c | 2 ++ 2 files changed, 4 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; } diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c index e28be51..34b8bd0 100644 --- a/arch/arm64/kvm/handle_exit.c +++ b/arch/arm64/kvm/handle_exit.c @@ -66,6 +66,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; }