From patchwork Tue Jun 12 05:16:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suraj Jitindar Singh X-Patchwork-Id: 10459313 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 0ED0D602A0 for ; Tue, 12 Jun 2018 05:18:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E10E926AE3 for ; Tue, 12 Jun 2018 05:18:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D1059274D0; Tue, 12 Jun 2018 05:18:31 +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=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 74AF426AE3 for ; Tue, 12 Jun 2018 05:18:31 +0000 (UTC) Received: from localhost ([::1]:52765 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSbhO-0001fy-Cz for patchwork-qemu-devel@patchwork.kernel.org; Tue, 12 Jun 2018 01:18:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39978) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSbg7-0000sq-0E for qemu-devel@nongnu.org; Tue, 12 Jun 2018 01:17:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fSbg6-0005tv-1c for qemu-devel@nongnu.org; Tue, 12 Jun 2018 01:17:10 -0400 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:44023) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fSbg1-0005hy-KW; Tue, 12 Jun 2018 01:17:05 -0400 Received: by mail-pl0-x241.google.com with SMTP id c41-v6so13656980plj.10; Mon, 11 Jun 2018 22:17:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=Mk4ZiCp5BOFeOGngi43VMnFecY16jE7+6Kg0ywoGf3w=; b=uNS+lRzQejc4daOLP+9El3jkqfhkrbVfv2yeU3Ouw1OLjQoRbQ1l5VZeaxnClSq4hM 2gNFyvHFv51JOd9dQtxt0cStGjGVAa2mZ7AZuCYeenwd243ocDlzxZbT3OFV4AA6d3u0 ubAsRHQrnk5OESwV0AfbiVQPQ+zw5OZNa+DSw6VdDAjPstLe1ubUpWg1o8CNsf31sA4c c8uE848458Pia7yb84O9koX2hDXqG4WiGx5Ei4Dl3syEfMAxerqkkxHwtQ7eekknvrUO LUVbkaMqYZzpZVtTofJbNd7+Dq4/QEHPJnILCjjsTVeZEo1BlUKv+8/aiLUTPUZceWWB uuYA== 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; bh=Mk4ZiCp5BOFeOGngi43VMnFecY16jE7+6Kg0ywoGf3w=; b=gPLvNMkklDKAed6ot2DiiuLVHkCSrius1pITf+3w3u7MA0IRjSOfkS+tsUe84R2Zd4 2tg4QQbk9OnBTfJ/r+YBczUVq7WsTiafbcDqYn5NpHZLXG31BLekWNbxAw+glDRPSS2S 3KxSu3vX+Hsz3vATRW9VeURwXfkvI8qpZfwcZQzKoxy1MFIISxqgstNP3AL9PlDUJos4 TBaXU1xaVEmAVp1fsTv5uLlR18F82GVMOSEVhLpinCNlu0C7M/SuSIZArbOr7cxqA8tq mjc2P1mHjvtfhwyszVBXWtEEXnCKMmmdwlhJX49xRf0H/PdL+fuBEjCaTFzn8PunlUrG 4pFQ== X-Gm-Message-State: APt69E0p30d324D5FQYiYGZ8Q8j25bf/WSO4x/seWfVO7ZebRQZbj43+ s161PC83qnNAKvkgLotXvmdLq8x9 X-Google-Smtp-Source: ADUXVKJbHLD5MlIjxIRqUnHO7LyQyIbXBV8bwoRB96wH4bQOjeLIk2cdot/u9xSI8y614EMkVq7C1w== X-Received: by 2002:a17:902:7406:: with SMTP id g6-v6mr2351539pll.90.1528780624515; Mon, 11 Jun 2018 22:17:04 -0700 (PDT) Received: from surajjs2.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id h78-v6sm58313pfh.141.2018.06.11.22.17.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Jun 2018 22:17:03 -0700 (PDT) From: Suraj Jitindar Singh To: qemu-ppc@nongnu.org Date: Tue, 12 Jun 2018 15:16:29 +1000 Message-Id: <20180612051630.17854-1-sjitindarsingh@gmail.com> X-Mailer: git-send-email 2.13.6 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::241 Subject: [Qemu-devel] [QEMU-PPC] [PATCH V2 1/2] target/ppc: Don't require private l1d cache on POWER8 for cap_ppc_safe_cache X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: groug@kaod.org, muriloo@linux.ibm.com, qemu-devel@nongnu.org, sjitindarsingh@gmail.com, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP For cap_ppc_safe_cache to be set to workaround, we require both a l1d cache flush instruction and private l1d cache. On POWER8 don't require private l1d cache. This means a guest on a POWER8 machine can make use of the cache flush workarounds. Signed-off-by: Suraj Jitindar Singh --- V1 -> V2: - Use mfpvr() to detect host type --- target/ppc/kvm.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 2c0c34e125..7fe9d0126b 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -2412,11 +2412,28 @@ bool kvmppc_has_cap_mmu_hash_v3(void) return cap_mmu_hash_v3; } +static bool kvmppc_power8_host(void) +{ + bool ret = false; +#ifdef TARGET_PPC64 + { + uint32_t base_pvr = CPU_POWERPC_POWER_SERVER_MASK & mfpvr(); + ret = (base_pvr == CPU_POWERPC_POWER8E_BASE) || + (base_pvr == CPU_POWERPC_POWER8NVL_BASE) || + (base_pvr == CPU_POWERPC_POWER8_BASE); + } +#endif /* TARGET_PPC64 */ + return ret; +} + static int parse_cap_ppc_safe_cache(struct kvm_ppc_cpu_char c) { + bool l1d_thread_priv_req = !kvmppc_power8_host(); + if (~c.behaviour & c.behaviour_mask & H_CPU_BEHAV_L1D_FLUSH_PR) { return 2; - } else if ((c.character & c.character_mask & H_CPU_CHAR_L1D_THREAD_PRIV) && + } else if ((!l1d_thread_priv_req || + c.character & c.character_mask & H_CPU_CHAR_L1D_THREAD_PRIV) && (c.character & c.character_mask & (H_CPU_CHAR_L1D_FLUSH_ORI30 | H_CPU_CHAR_L1D_FLUSH_TRIG2))) { return 1;