From patchwork Sun Aug 18 16:57:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 171573 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1974030ily; Sun, 18 Aug 2019 09:57:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqycaLJ0svwh8XHZAqoEvYVoo0+JTRgi8h8wyuIcs8ZF8nn26Fksm5wZKt3sGAWPAKg1bK6q X-Received: by 2002:a17:90b:f13:: with SMTP id br19mr16721212pjb.124.1566147443864; Sun, 18 Aug 2019 09:57:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566147443; cv=none; d=google.com; s=arc-20160816; b=OVBrtUtSiqgYvjIs/kKywugBqWz3TVltqFQlxqdgX6FCohIMPht3I8h3UrlBvw2Udo AYPkDqNLfdtletg6QxcmZt1x7Mf9E3DyQNHlKy3LSyzc4dXGc0lLNFyph3GKwsmJuqOi C+hLFLP53tui2TABuz5t7nBI1nD0Sui3gNT8K8pBfCV+NuiTaMGaHNea0JFQamJkS51W 4YfndcWqR6j10ZC0NjWFyrZ0Tj+NLhU60OySNRLxzvwWAogeDhGBo2PUIWBwNRSRcNey CxdO/9IxNox/h4fSkXjYTAShQaXdKdg3yIQ7IVx4IVJxkYbI3ZRo+irBYOgxs45XZzBW 059g== 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=oKhZ/8+tEjZipLDvwvRLQhDtkEAI/tBQWmSh1G0/Nvg=; b=OyS9s4/9jQjq8kL1ad6PpPBaXP7OAtl/4+Z7c07G/d6vAEu/xKtuLQH2LpIdZ0WbW2 JTvKSKQb/AvqbgNk9I6sPoUzrGXxUSPazQxzBNJtPJUiQwQQqsXrlEtAIEgmUH7xUfxG Lkc7SzEJD9Upm/H9pUYFpoSaz8PVe1wKqhdBbVsVItJm4nATw0OfPQwBZGXOth6UYARa N5P0J4cZ1Z5qs2rgACWG7RQ7ydG0LiXpYCWibzPAHV0bzWZDK1DSgHIsENYAgJjqt3TK 9XiJIiMpBE/kBbTFQhjv3bw6SVlsFvyfiiM0tjN3CQAk4hGksmPIZ/+54awBRTi5J8K9 OkZg== 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.57.23; Sun, 18 Aug 2019 09:57:23 -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 S1726903AbfHRQ5X (ORCPT + 14 others); Sun, 18 Aug 2019 12:57:23 -0400 Received: from foss.arm.com ([217.140.110.172]:46556 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726608AbfHRQ5X (ORCPT ); Sun, 18 Aug 2019 12:57:23 -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 5F122337; Sun, 18 Aug 2019 09:57:22 -0700 (PDT) Received: from why.lan (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C42D23F706; Sun, 18 Aug 2019 09:57:21 -0700 (PDT) From: Marc Zyngier To: stable@vger.kernel.org Cc: Anders Roxell Subject: [4.19-stable][PATCH] arm64: KVM: regmap: Fix unexpected switch fall-through Date: Sun, 18 Aug 2019 17:57:08 +0100 Message-Id: <20190818165708.1169-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 7a5173ea2276..4c2e96ef306e 100644 --- a/arch/arm64/kvm/regmap.c +++ b/arch/arm64/kvm/regmap.c @@ -189,13 +189,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; } }