From patchwork Mon Dec 18 10:00:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 122200 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2624375qgn; Mon, 18 Dec 2017 02:01:22 -0800 (PST) X-Google-Smtp-Source: ACJfBovolug6K4vOdgXx5+/EUlipvcugzcQE0VQ3Pyk43l4I6QcAwQbrvxcy7PQSUNxfrYnVjJU2 X-Received: by 10.84.164.162 with SMTP id w31mr17652748pla.388.1513591282016; Mon, 18 Dec 2017 02:01:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513591282; cv=none; d=google.com; s=arc-20160816; b=XrlpNg+4FYimNcc01BNlswBkAbqadqZki/nT3rDvCnyL5DVj4M83ecEaV/eHNe9Fo/ ratYmJxyV/QZRVZFUshANrHQ5SdHzxyhOji3LOMhiKy2miu19y6TiOvyfD9k8A3POeli E6LhkSTyxHAzHzAVq5JXXImeZg30ZojX/6ZdSHVWP1/l1CFGuhxPS54fIi7lHBrqDReg OxU1B36h77j0Wg/PqbL56gqSdN5yTdfI4yr1MNE5/o0FeRcNizg9PRSBgEtZZ1k/rcCt cU942nbf4C4DN4QJg6266f7DoANq4QIF7d1uYbbt3tBhTyCxaqDmO8zTDih8PDtva4Yb jHjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=P+A629uczMBDRbROdrM6MqYr9nyBieUI3jf+421np7E=; b=ckjliEryS1dkIh64sX/eOgfEqhW0ysfyDYbCGWvWszGAXC8gk3btR/CWdcSALtNTD2 be5BhMKEWqz8pV/lUfD/PBWDzyogLDu0DMBgdNLLMl1odUWx1c4fzLcXc10OKG+c3SbL +DnA81xk3Zxn3mDt0AI5npyUnH5N6ShleLxM9u15AuwcWYaaGbqzM6Er3HoYaObMAHqW fXx5Tbz4zmq3qasWI6L2HdDgoA/sNSqpuvkOLJgRp+dEL/QV03lh3jYck1kJ7HKgsApU 0lAs+G43Ko2KUzWDQl6KCW3hkSr4+dkgYmOEepdntN3eWJN/zSmzRzioT0kvckBeBw/L 01Xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=i/oPwsgd; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z23si8319207pgc.428.2017.12.18.02.01.21; Mon, 18 Dec 2017 02:01:22 -0800 (PST) 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; dkim=pass header.i=@linaro.org header.s=google header.b=i/oPwsgd; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758415AbdLRKBU (ORCPT + 10 others); Mon, 18 Dec 2017 05:01:20 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:45259 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758348AbdLRKBS (ORCPT ); Mon, 18 Dec 2017 05:01:18 -0500 Received: by mail-wm0-f68.google.com with SMTP id 9so27958547wme.4 for ; Mon, 18 Dec 2017 02:01:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=P+A629uczMBDRbROdrM6MqYr9nyBieUI3jf+421np7E=; b=i/oPwsgd7HjnQcLSaYVuxRepMvXyQRL9/IO9k6CrasC+o4qmnH0sPftCEtLoBh/fW8 v0LZgZO/syC6KaULdsohFtV4zDCgRcVJ5copgY65X0jZmyY+QV/9xdqSU5FY6+0rZja/ cKzU4yYZb2WyJvyUavWkGDzMWFiZGYLdc0a4o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=P+A629uczMBDRbROdrM6MqYr9nyBieUI3jf+421np7E=; b=NKK/sef1bTPxEdbhXTDO6X+NZJRbHsC/ikYbObjpSuJxP3X8677OOMsJYHY+fSxFhV 2csPspZ/vAdxjhmwAka3GEjQjXcCFNVE+/g0JQIvZOqJoSYYEY2nEc7oRtES+JnZP1Oi VdjgQv2LwvVdeJ3iYUesNwRzWsYakPnsss/DY74Hym4LHlJifxbtFmbotgSioCXZyiTZ Gmdgy6SHAyJMR1Nt2OFCH5MCLQHhJDDn2N3nhAFBxI5y9F5RLmA93Q+l5qMVo8d0lX8F /quDV6jSBRr7gDGrMjLAK0fWNpNsvOUR/w1ztfeKgbk1xIHFfloYFD5v1wc3y+hoZkWe zxsg== X-Gm-Message-State: AKGB3mJdVSZvssMTRkTMp6Fg7xkkfKZ8qW789qjI4AOrf6Ucs9tFkQKf PxiqRApdfjOr3g9lSNxSyNOaWw== X-Received: by 10.80.195.12 with SMTP id a12mr29120426edb.142.1513591277315; Mon, 18 Dec 2017 02:01:17 -0800 (PST) Received: from localhost.localdomain (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id h16sm10403130edj.34.2017.12.18.02.01.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 18 Dec 2017 02:01:16 -0800 (PST) From: Christoffer Dall To: Paolo Bonzini , =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= Cc: Marc Zyngier , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, Julien Thierry , Christoffer Dall , Catalin Marinas , stable@vger.kernel.org Subject: [PULL 1/5] arm64: kvm: Prevent restoring stale PMSCR_EL1 for vcpu Date: Mon, 18 Dec 2017 11:00:53 +0100 Message-Id: <20171218100057.7839-2-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171218100057.7839-1-christoffer.dall@linaro.org> References: <20171218100057.7839-1-christoffer.dall@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Julien Thierry When VHE is not present, KVM needs to save and restores PMSCR_EL1 when possible. If SPE is used by the host, value of PMSCR_EL1 cannot be saved for the guest. If the host starts using SPE between two save+restore on the same vcpu, restore will write the value of PMSCR_EL1 read during the first save. Make sure __debug_save_spe_nvhe clears the value of the saved PMSCR_EL1 when the guest cannot use SPE. Signed-off-by: Julien Thierry Cc: Christoffer Dall Cc: Marc Zyngier Cc: Catalin Marinas Cc: Reviewed-by: Will Deacon Reviewed-by: Christoffer Dall Signed-off-by: Christoffer Dall --- arch/arm64/kvm/hyp/debug-sr.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.14.2 diff --git a/arch/arm64/kvm/hyp/debug-sr.c b/arch/arm64/kvm/hyp/debug-sr.c index 321c9c05dd9e..f4363d40e2cd 100644 --- a/arch/arm64/kvm/hyp/debug-sr.c +++ b/arch/arm64/kvm/hyp/debug-sr.c @@ -74,6 +74,9 @@ static void __hyp_text __debug_save_spe_nvhe(u64 *pmscr_el1) { u64 reg; + /* Clear pmscr in case of early return */ + *pmscr_el1 = 0; + /* SPE present on this CPU? */ if (!cpuid_feature_extract_unsigned_field(read_sysreg(id_aa64dfr0_el1), ID_AA64DFR0_PMSVER_SHIFT))