From patchwork Fri Jan 19 05:00:05 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: 10174563 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 2C0EB60392 for ; Fri, 19 Jan 2018 05:18:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1177228575 for ; Fri, 19 Jan 2018 05:18:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 03E2728583; Fri, 19 Jan 2018 05:18:18 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 7BF5828575 for ; Fri, 19 Jan 2018 05:18:17 +0000 (UTC) Received: from localhost ([::1]:53295 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecP4C-0005N9-PJ for patchwork-qemu-devel@patchwork.kernel.org; Fri, 19 Jan 2018 00:18:16 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60407) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecOnF-0007fc-Iq for qemu-devel@nongnu.org; Fri, 19 Jan 2018 00:00:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ecOnE-0004ty-KT for qemu-devel@nongnu.org; Fri, 19 Jan 2018 00:00:45 -0500 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:40625) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ecOn9-0004su-A7; Fri, 19 Jan 2018 00:00:39 -0500 Received: by mail-pg0-x244.google.com with SMTP id g16so558456pgn.7; Thu, 18 Jan 2018 21:00:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=oRr9tacZ2WbFsP/oLcwfTnHJyR01rux/tA+WuyGPvGY=; b=ruYmnoxT+opLDeb5a58M9w0YfJS94TdEfIbK60qRUFgJ/zGJbH3hFLbtJa8lIWVcgL y+znMJ0n/BjTAryl7l+p4LiBTBJLGPOQsIUdaaklTn/sCf031xif/X0c/y6261+tAC8Y 2Lg+Uq087eBALTFdYX4QLXyLJKykCMAYkwtBLn+EfCzSupgj96PQHRzKLxjJZFfvq8xc WQ9RgeZgsGOQZoi+S+QXogJ7gG6cbNoeQUP62P1Y9TTNe1dmM+HeEK+u/j7IK+F83GEa LL9DIM9MC4WiOUDc5KnzADdpYsQ0R1NiYeRvBwNget8YwzCRwzXVINPZqMqLvE+x6BbX eFDQ== 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=oRr9tacZ2WbFsP/oLcwfTnHJyR01rux/tA+WuyGPvGY=; b=gKGJzXsIfYPUnsFyEa6O+93/OciDg5SeJzhgHVFWi0VqVyRp27OSCCoAfl5ifBmLgw WOWTgrOZ9X5UC1i+M617/5nV9/hKW1sJZGVHUG4U1dVZm4lHMb9KAJWei4+wjEANrQ8U zQjxrTjLO0KhmGNzPE6VTTT5x7yrcf6eTZOZc5JBWXbKAEa/8zhv9xJqiFlBglmOVTC/ sc0oMJtAYy0+flVsJc0FdZdw4vKQq61kQLYq2A6Jr9T7SO/v+6ozjxw3T8eweVdgfbp8 kEPwqMRRsgQuhg/xnrmY4pTcRb2mJMCqG7EIbm9QDEVb54tPQ3oVH30/zvapycGpq4gt C20Q== X-Gm-Message-State: AKwxytet+5jkQvZAzKJvUPIPvyR/OQvk8YPSn2+6yOquuOEkQaXh/NtX 5HlwcHQDCFhS+/wrmNEU7UbrAyIV X-Google-Smtp-Source: ACJfBossTqWd1b75gSdtKulxXGasMb6Cv/PN+TCUJsgop0+mc1QEcK4g70CIsMzgjagm47Au7ah2nQ== X-Received: by 2002:a17:902:5853:: with SMTP id f19-v6mr975025plj.383.1516338037960; Thu, 18 Jan 2018 21:00:37 -0800 (PST) Received: from surajjs1.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id i128sm14653163pfg.83.2018.01.18.21.00.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Jan 2018 21:00:37 -0800 (PST) From: Suraj Jitindar Singh To: qemu-ppc@nongnu.org Date: Fri, 19 Jan 2018 16:00:05 +1100 Message-Id: <20180119050005.29392-8-sjitindarsingh@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180119050005.29392-1-sjitindarsingh@gmail.com> References: <20180119050005.29392-1-sjitindarsingh@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::244 Subject: [Qemu-devel] [QEMU-PPC] [PATCH V5 7/7] target/ppc/spapr: Add H-Call H_GET_CPU_CHARACTERISTICS 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: paulus@ozlabs.org, qemu-devel@nongnu.org, Suraj Jitindar Singh , 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 The new H-Call H_GET_CPU_CHARACTERISTICS is used by the guest to query behaviours and available characteristics of the cpu. Implement the handler for this new H-Call which formulates its response based on the setting of the spapr_caps cap-cfpc, cap-sbbc and cap-ibs. Signed-off-by: Suraj Jitindar Singh --- V4 -> V5: - Assert for invalid cap value --- hw/ppc/spapr_hcall.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/hw/ppc/spapr.h | 1 + 2 files changed, 59 insertions(+) diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index 51eba52e86..4d0e6eb0cf 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -1654,6 +1654,60 @@ static target_ulong h_client_architecture_support(PowerPCCPU *cpu, return H_SUCCESS; } +static target_ulong h_get_cpu_characteristics(PowerPCCPU *cpu, + sPAPRMachineState *spapr, + target_ulong opcode, + target_ulong *args) +{ + uint64_t characteristics = H_CPU_CHAR_HON_BRANCH_HINTS & + ~H_CPU_CHAR_THR_RECONF_TRIG; + uint64_t behaviour = H_CPU_BEHAV_FAVOUR_SECURITY; + uint8_t safe_cache = spapr_get_cap(spapr, SPAPR_CAP_CFPC); + uint8_t safe_bounds_check = spapr_get_cap(spapr, SPAPR_CAP_SBBC); + uint8_t safe_indirect_branch = spapr_get_cap(spapr, SPAPR_CAP_IBS); + + switch (safe_cache) { + case SPAPR_CAP_WORKAROUND: + characteristics |= H_CPU_CHAR_L1D_FLUSH_ORI30; + characteristics |= H_CPU_CHAR_L1D_FLUSH_TRIG2; + characteristics |= H_CPU_CHAR_L1D_THREAD_PRIV; + behaviour |= H_CPU_BEHAV_L1D_FLUSH_PR; + break; + case SPAPR_CAP_FIXED: + break; + default: /* broken */ + assert(safe_cache == SPAPR_CAP_BROKEN); + behaviour |= H_CPU_BEHAV_L1D_FLUSH_PR; + break; + } + + switch (safe_bounds_check) { + case SPAPR_CAP_WORKAROUND: + characteristics |= H_CPU_CHAR_SPEC_BAR_ORI31; + behaviour |= H_CPU_BEHAV_BNDS_CHK_SPEC_BAR; + break; + case SPAPR_CAP_FIXED: + break; + default: /* broken */ + assert(safe_bounds_check == SPAPR_CAP_BROKEN); + behaviour |= H_CPU_BEHAV_BNDS_CHK_SPEC_BAR; + break; + } + + switch (safe_indirect_branch) { + case SPAPR_CAP_FIXED: + characteristics |= H_CPU_CHAR_BCCTRL_SERIALISED; + default: /* broken */ + assert(safe_indirect_branch == SPAPR_CAP_BROKEN); + break; + } + + args[0] = characteristics; + args[1] = behaviour; + + return H_SUCCESS; +} + static spapr_hcall_fn papr_hypercall_table[(MAX_HCALL_OPCODE / 4) + 1]; static spapr_hcall_fn kvmppc_hypercall_table[KVMPPC_HCALL_MAX - KVMPPC_HCALL_BASE + 1]; @@ -1733,6 +1787,10 @@ static void hypercall_register_types(void) spapr_register_hypercall(H_INVALIDATE_PID, h_invalidate_pid); spapr_register_hypercall(H_REGISTER_PROC_TBL, h_register_process_table); + /* hcall-get-cpu-characteristics */ + spapr_register_hypercall(H_GET_CPU_CHARACTERISTICS, + h_get_cpu_characteristics); + /* "debugger" hcalls (also used by SLOF). Note: We do -not- differenciate * here between the "CI" and the "CACHE" variants, they will use whatever * mapping attributes qemu is using. When using KVM, the kernel will diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 549d7a4134..62c077ac20 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -404,6 +404,7 @@ struct sPAPRMachineState { #define H_GET_HCA_INFO 0x1B8 #define H_GET_PERF_COUNT 0x1BC #define H_MANAGE_TRACE 0x1C0 +#define H_GET_CPU_CHARACTERISTICS 0x1C8 #define H_FREE_LOGICAL_LAN_BUFFER 0x1D4 #define H_QUERY_INT_STATE 0x1E4 #define H_POLL_PENDING 0x1D8