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: 10118687 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E585B6019C for ; Mon, 18 Dec 2017 10:02:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D375E28DB1 for ; Mon, 18 Dec 2017 10:02:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C870428E35; Mon, 18 Dec 2017 10:02:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D13B028DB1 for ; Mon, 18 Dec 2017 10:02:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=SMcae+bnrERllpMkAwBq7SEcJ5wKLvWUbRFk1rIy11I=; b=XzCzWOz+a9I0hYEue3MzAksBp0 CjvNUVfnUr5teCvsoYeR54oaz4lRQ2mfjqx4Vw2Qw17MNAzF4GHn7MIh3MQfoKt0rZgKu26pCkDWt OzOzma6pZ52oe10l9XUsGBZM+kQbY/DOnysfqgaQYaf07+RYePDa5gNowugumY52rMp836kQxSngl fG71GVMjCnUh2tmhOLlhuJSL2EcX30Boyb2md3estrdh76DKBAB0W/Rq/qrDDK90RRLtvCDCZNKOi 0yZg7z1xhYpYBj53t3d6x/5bP8pYtE6LQyxfAT3zm8sI/m+CXyxAAazfus3LVFuopAP+9GliBDYza oA8Vg02Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eQsFZ-0007fg-64; Mon, 18 Dec 2017 10:02:21 +0000 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eQsEr-0006pm-Sr for linux-arm-kernel@lists.infradead.org; Mon, 18 Dec 2017 10:01:44 +0000 Received: by mail-wm0-x243.google.com with SMTP id t8so27968373wmc.3 for ; Mon, 18 Dec 2017 02:01:18 -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=cNKrUztIDeBSOKyIxQSu0OGE0T9d6xX53AFs71wJpqtceHsXStmd1EZPmZ8FGi1gtg ipZrsMjla1AjoBC7BzfzeQJaHTL7WMJOOSx6I+pnNHCXDUYsuYQzgCChi07Mv4WfUHAm wFvmpch0RCJU5ix4dR0tykRvd/2luiyn+HVli74fU9Qekp6u+jm3BKh8LMQa677O9yXY C4+gPL5qSP4X2GpxcDgcUBOoqzywyH2JJ8GCYzNwc0QfeA+kmJnao7UwLIpY7xBJWCsV k90S8dqW470chaFI2a+VuH8jlMpTBbdbXFNub86lbpJ8CqjLupzPqv7pAkpyBE8hyyu9 FzZg== X-Gm-Message-State: AKGB3mLHSdjtyPk0/A2Dl6E769sZbx7E5TyUcHPFveJQZXJHZ+pDyHJF JPOExC0U1tlSP7KYy1s9Z2OR9Q== X-Google-Smtp-Source: ACJfBosVpVd+3110tPrffk4qX3AvWJwNW/VO+VOucGUtyfHlSQjV/LdD96+dXyJWjYX7fyU/Xpg9pg== 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?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171218_020138_121567_A5A1722D X-CRM114-Status: GOOD ( 11.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kvm@vger.kernel.org, Julien Thierry , Marc Zyngier , Catalin Marinas , stable@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, Christoffer Dall MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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(+) 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))