From patchwork Sun Aug 18 16:55:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 171572 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1972830ily; Sun, 18 Aug 2019 09:55:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqzTacTnd1nyz2KoiMXDrcQPypD2tQ7DUbVQAOAsnK1M31YSsX1ztDSdQYiWBCmoC9T8/m+S X-Received: by 2002:aa7:91ca:: with SMTP id z10mr20459588pfa.30.1566147337769; Sun, 18 Aug 2019 09:55:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566147337; cv=none; d=google.com; s=arc-20160816; b=ZAdOI3209/cUfekFiu6XB0kUB0S9Q4bIyyNDKaNd2ay+PADlsTeEs7HoHKRXrjsYtG 6iEG8gqhblE7AGghJTJt5OlYr0wX+st6x/G76hfpjwmKJocZrXxOlOVMsowKlRlXcZla ZzybwDtPVk3rI5JFIcIdxERl19/OtpGNef5HovQgPp1jVUYmkv/dRsREgYb5OxK++YUC gd8jiLQ8gNk5+qyiXUbW41y/eaMgY2A4fHGaXmZ0O4XdR46ZBcf7rxxw4zrBV6DBFftR oLOfpalTwohY1odK52aD/G9R43rRwPh//IH/rXflCetR1CdDcY9vEFVLLwCI0EyrakeW 9GdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=eCyePtOciz8hdkinXioX++UJRR7lo2KMxqnqVRoU1Oc=; b=njov/wmUmbcZGEqtgdLNLPE5wnMAk7K7L5IycT+keQAmvl2aLA19Eb74zXqOzFYLWY lN1z3pcK0HqWbC6czpd2xNMTqN5EKu1tckAQFpfGiuNI3TbbYbeZRXULBcrvOIiA0O2F H+HRR8+Wop7MZHGeXnfRql7KJBnsuy0Whc2lw1hXH4rH0a0EJ8ddgQpfIzZzbBt77nmZ 6pNrqewe8R4zQJaBhm7Jrg77RTqXkdLxNtDiX1LjALT6fjegw1MAgLLgHWdO39584YEs aeZoJcpwVAlyEj3LTV2p7DRMZ9WXfyGqzpLLJCeN0MCc17PxDxAKECcNvJW6iEnl9MqB f1Ug== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y3si6909306pgp.19.2019.08.18.09.55.37; Sun, 18 Aug 2019 09:55:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726097AbfHRQzh (ORCPT + 14 others); Sun, 18 Aug 2019 12:55:37 -0400 Received: from foss.arm.com ([217.140.110.172]:46546 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726115AbfHRQzg (ORCPT ); Sun, 18 Aug 2019 12:55:36 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E86EE337; Sun, 18 Aug 2019 09:55:35 -0700 (PDT) Received: from why.lan (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5E6933F706; Sun, 18 Aug 2019 09:55:35 -0700 (PDT) From: Marc Zyngier To: stable@vger.kernel.org Cc: Anders Roxell Subject: [5.2-stable][PATCH] arm64: KVM: regmap: Fix unexpected switch fall-through Date: Sun, 18 Aug 2019 17:55:29 +0100 Message-Id: <20190818165529.835-1-maz@kernel.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Anders Roxell commit 3d584a3c85d6fe2cf878f220d4ad7145e7f89218 upstream. When fall-through warnings was enabled by default, commit d93512ef0f0e ("Makefile: Globally enable fall-through warning"), the following warnings was starting to show up: In file included from ../arch/arm64/include/asm/kvm_emulate.h:19, from ../arch/arm64/kvm/regmap.c:13: ../arch/arm64/kvm/regmap.c: In function ‘vcpu_write_spsr32’: ../arch/arm64/include/asm/kvm_hyp.h:31:3: warning: this statement may fall through [-Wimplicit-fallthrough=] asm volatile(ALTERNATIVE(__msr_s(r##nvh, "%x0"), \ ^~~ ../arch/arm64/include/asm/kvm_hyp.h:46:31: note: in expansion of macro ‘write_sysreg_elx’ #define write_sysreg_el1(v,r) write_sysreg_elx(v, r, _EL1, _EL12) ^~~~~~~~~~~~~~~~ ../arch/arm64/kvm/regmap.c:180:3: note: in expansion of macro ‘write_sysreg_el1’ write_sysreg_el1(v, SYS_SPSR); ^~~~~~~~~~~~~~~~ ../arch/arm64/kvm/regmap.c:181:2: note: here case KVM_SPSR_ABT: ^~~~ In file included from ../arch/arm64/include/asm/cputype.h:132, from ../arch/arm64/include/asm/cache.h:8, from ../include/linux/cache.h:6, from ../include/linux/printk.h:9, from ../include/linux/kernel.h:15, from ../include/asm-generic/bug.h:18, from ../arch/arm64/include/asm/bug.h:26, from ../include/linux/bug.h:5, from ../include/linux/mmdebug.h:5, from ../include/linux/mm.h:9, from ../arch/arm64/kvm/regmap.c:11: ../arch/arm64/include/asm/sysreg.h:837:2: warning: this statement may fall through [-Wimplicit-fallthrough=] asm volatile("msr " __stringify(r) ", %x0" \ ^~~ ../arch/arm64/kvm/regmap.c:182:3: note: in expansion of macro ‘write_sysreg’ write_sysreg(v, spsr_abt); ^~~~~~~~~~~~ ../arch/arm64/kvm/regmap.c:183:2: note: here case KVM_SPSR_UND: ^~~~ Rework to add a 'break;' in the swich-case since it didn't have that, leading to an interresting set of bugs. Cc: stable@vger.kernel.org # v4.17+ Fixes: a892819560c4 ("KVM: arm64: Prepare to handle deferred save/restore of 32-bit registers") Signed-off-by: Anders Roxell [maz: reworked commit message, fixed stable range] Signed-off-by: Marc Zyngier --- arch/arm64/kvm/regmap.c | 5 +++++ 1 file changed, 5 insertions(+) -- 2.20.1 diff --git a/arch/arm64/kvm/regmap.c b/arch/arm64/kvm/regmap.c index d66613e6ad08..8a38ccf8dc02 100644 --- a/arch/arm64/kvm/regmap.c +++ b/arch/arm64/kvm/regmap.c @@ -178,13 +178,18 @@ void vcpu_write_spsr32(struct kvm_vcpu *vcpu, unsigned long v) switch (spsr_idx) { case KVM_SPSR_SVC: write_sysreg_el1(v, spsr); + break; case KVM_SPSR_ABT: write_sysreg(v, spsr_abt); + break; case KVM_SPSR_UND: write_sysreg(v, spsr_und); + break; case KVM_SPSR_IRQ: write_sysreg(v, spsr_irq); + break; case KVM_SPSR_FIQ: write_sysreg(v, spsr_fiq); + break; } }