From patchwork Thu Sep 18 18:18:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 37598 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C6A932054E for ; Thu, 18 Sep 2014 18:18:41 +0000 (UTC) Received: by mail-wg0-f71.google.com with SMTP id x12sf868294wgg.6 for ; Thu, 18 Sep 2014 11:18:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=nCYb+jWEKBfrLGDJnKqFzmPpeyxaKqSMyJqKUt174ZU=; b=ej4JItdouHFFjpS1vN9BznZSvFclt4yRlIJIEA2UGKYr0rWdmTv0NIP/7hilq6RTOn 7IP8pDAkQC+V1M+//0KCrRDIa14bNJSQZtn1gbemW1hNTwisKOBSleF+hknW3pqltvky qzmTOtxDmLJQ4WD9Y4noquX+NY9kmwu3dmIafpUaYZYG5Wx8fk1h6h+PKaRmJ2nPFBjK ApWwYuc3cbvbeVdzrxLhfODAmGcFQ5uyGJMqibzkdekZfHF0l0trWwhkhD2E++q6j/9j RRUBiNJHbW6sLkI6D+5Xx5EPUes30COCDlzvKqBcPY6eKvLiPk7KkOOOg/QEN00C+k9B yAng== X-Gm-Message-State: ALoCoQmUIfI1wta17uRJl8d7+Au67jA1fL5U7penky5B4XdWyv/KIQrcImtvog21tBP8x/vLjol6 X-Received: by 10.112.157.193 with SMTP id wo1mr303999lbb.19.1411064320889; Thu, 18 Sep 2014 11:18:40 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.29.135 with SMTP id k7ls182874lah.78.gmail; Thu, 18 Sep 2014 11:18:40 -0700 (PDT) X-Received: by 10.112.114.202 with SMTP id ji10mr1445336lbb.92.1411064320656; Thu, 18 Sep 2014 11:18:40 -0700 (PDT) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com [209.85.217.179]) by mx.google.com with ESMTPS id bc10si33988666lab.15.2014.09.18.11.18.40 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 18 Sep 2014 11:18:40 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) client-ip=209.85.217.179; Received: by mail-lb0-f179.google.com with SMTP id 10so1226593lbg.10 for ; Thu, 18 Sep 2014 11:18:40 -0700 (PDT) X-Received: by 10.112.163.103 with SMTP id yh7mr1301928lbb.73.1411064320137; Thu, 18 Sep 2014 11:18:40 -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.112.130.169 with SMTP id of9csp809923lbb; Thu, 18 Sep 2014 11:18:39 -0700 (PDT) X-Received: by 10.67.3.106 with SMTP id bv10mr8267092pad.13.1411064318478; Thu, 18 Sep 2014 11:18:38 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cb9si41097524pdb.107.2014.09.18.11.18.37 for ; Thu, 18 Sep 2014 11:18:38 -0700 (PDT) Received-SPF: none (google.com: stable-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932424AbaIRSSh (ORCPT + 1 other); Thu, 18 Sep 2014 14:18:37 -0400 Received: from mail-pd0-f176.google.com ([209.85.192.176]:60890 "EHLO mail-pd0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932117AbaIRSSg (ORCPT ); Thu, 18 Sep 2014 14:18:36 -0400 Received: by mail-pd0-f176.google.com with SMTP id g10so1922706pdj.7 for ; Thu, 18 Sep 2014 11:18:36 -0700 (PDT) X-Received: by 10.68.173.101 with SMTP id bj5mr8552607pbc.15.1411064316170; Thu, 18 Sep 2014 11:18:36 -0700 (PDT) Received: from ards-macbook-pro.swisscom.com (70-35-38-154.static.wiline.com. [70.35.38.154]) by mx.google.com with ESMTPSA id je2sm20269253pbd.94.2014.09.18.11.18.33 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 18 Sep 2014 11:18:34 -0700 (PDT) From: Ard Biesheuvel To: michael.hudson@linaro.org Cc: Christoffer Dall , , Ard Biesheuvel Subject: [PATCH] arm/arm64: KVM: Complete WFI/WFE instructions Date: Thu, 18 Sep 2014 11:18:28 -0700 Message-Id: <1411064308-28382-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 Sender: stable-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: stable@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@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.217.179 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 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Christoffer Dall 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: Acked-by: Marc Zyngier Cc: Ard Biesheuvel Signed-off-by: Christoffer Dall --- 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 4c979d466cc1..a96a8043277c 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 e28be510380c..34b8bd0711e9 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; }