From patchwork Tue Dec 11 15:20:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Lindsay X-Patchwork-Id: 10724041 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 90F9C1759 for ; Tue, 11 Dec 2018 15:31:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F7232B387 for ; Tue, 11 Dec 2018 15:31:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 73B8C2B38A; Tue, 11 Dec 2018 15:31:29 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 A6BC92B387 for ; Tue, 11 Dec 2018 15:31:28 +0000 (UTC) Received: from localhost ([::1]:38679 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gWk0M-0003u4-Fc for patchwork-qemu-devel@patchwork.kernel.org; Tue, 11 Dec 2018 10:31:26 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57600) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gWjqK-0004MU-3M for qemu-devel@nongnu.org; Tue, 11 Dec 2018 10:21:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gWjqJ-0001le-5C for qemu-devel@nongnu.org; Tue, 11 Dec 2018 10:21:04 -0500 Received: from mail-eopbgr810121.outbound.protection.outlook.com ([40.107.81.121]:63664 helo=NAM01-BY2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gWjqB-0001f6-AN; Tue, 11 Dec 2018 10:20:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amperemail.onmicrosoft.com; s=selector1-os-amperecomputing-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=91fD/EZWz/GT/VNB8YbzKnIaGDQGj+PCnQWISQd3Gz0=; b=Ou338PWiEF7dmhadMfGNGAMg8H093aPJFfrtwOymXxsDndBoPLJaznFZj8R71TMRmB60mUpR5sm1DiRHawI2+emMKpHFs8nHDbOwuoXz9qiEu2RjmsvKKYH5bMX7Pwxsg7rftdU6fZSufm+l6GnCX27C3hvY6k3WXjHPReyXR58= Received: from DM6PR01MB4825.prod.exchangelabs.com (20.177.218.222) by DM6PR01MB4601.prod.exchangelabs.com (20.177.216.78) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1404.21; Tue, 11 Dec 2018 15:20:52 +0000 Received: from DM6PR01MB4825.prod.exchangelabs.com ([fe80::9c7c:27c7:4cb7:f820]) by DM6PR01MB4825.prod.exchangelabs.com ([fe80::9c7c:27c7:4cb7:f820%2]) with mapi id 15.20.1404.026; Tue, 11 Dec 2018 15:20:52 +0000 From: Aaron Lindsay To: "qemu-arm@nongnu.org" , Peter Maydell , Alistair Francis , Wei Huang , Peter Crosthwaite , Richard Henderson Thread-Topic: [PATCH v10 13/14] target/arm: Implement PMSWINC Thread-Index: AQHUkWUahT3AJDLCXk6/s6lK2runEA== Date: Tue, 11 Dec 2018 15:20:52 +0000 Message-ID: <20181211151945.29137-14-aaron@os.amperecomputing.com> References: <20181211151945.29137-1-aaron@os.amperecomputing.com> In-Reply-To: <20181211151945.29137-1-aaron@os.amperecomputing.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BYAPR11CA0041.namprd11.prod.outlook.com (2603:10b6:a03:80::18) To DM6PR01MB4825.prod.exchangelabs.com (2603:10b6:5:6b::30) authentication-results: spf=none (sender IP is ) smtp.mailfrom=aaron@os.amperecomputing.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [65.190.6.212] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DM6PR01MB4601; 6:aHkpq1u2zhslae7e3ql0nTSbexD758aYjNazwcexf0Ncq/r6+4qqf6XdiECfrNWFGob1wh8VI0zLgFdEBFQK+GjnegUoqTrCjMXaz+ufFziMRWA3S1e20LOq0TzLBH7h6hL9K+BhkDu18pY2sQ86sGawQmm6D03Hdvvs3VTi+DdqRgLlYX/UYyPrU0f1MqMqkjydCyCD+j3X4wjLtwM78aQ3TUAjgvLTkV/C10rq+j+D9Ejb2Yrf8ou0bqn1yzsetRHT11nnMpCsZe2/o4ZmWQpmyXQaWKRo3IQB+2UrNbB+Y+oXN3/3yOtdbfQQNag/h1dgKY+BXVm/ILdIV2X9b3OqkoNg+7F/CwiKOjRKdeafrvVliT2ssimc22neNLiZd9xB2WTshFTNPdZkjkqW8Osc18/7ITm0FAeWxmgvX4CFjKeKWNf+c3vTuxN5TfczgJz0NBAEqlJ585AlePevjQ==; 5:xmUQ9dbUGN5KYjZ1N1pJOYV8Zyut8JKG4J2D7hcNendX0g/Wjex69cUlEyFsECF2rKO4nrypALqLGf4rmJE7iQ02mSSzE/luVcpLQZMlv8X2q5TQxxqCETBKFRdtaBZ8IZAaM4XX9rfxW8kg5zThFF1SKkQ3EkXfjgzsNdjxESE=; 7:3Ow8HVYGvbYZCqNZPXlHJlaWYhQ+Em4n14i6K3rFd4WbJg6y0WdEF4FaJgVLgZRfc/xTU8o+f+JVxrCfLS6GxYGU60RyN+EIyinRuWI/oFEKOcD1fbT4mYhyztmqfI5GdBqkIZS/D+ZBO/dbemdJsw== x-ms-office365-filtering-correlation-id: 9a098bc7-7962-4401-b83d-08d65f7c3d18 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:DM6PR01MB4601; x-ms-traffictypediagnostic: DM6PR01MB4601: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231455)(999002)(944501520)(52105112)(10201501046)(3002001)(93006095)(93001095)(148016)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:DM6PR01MB4601; BCL:0; PCL:0; RULEID:; SRVR:DM6PR01MB4601; x-forefront-prvs: 08831F51DC x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(396003)(39850400004)(366004)(346002)(376002)(136003)(199004)(189003)(66066001)(7416002)(54906003)(106356001)(2906002)(97736004)(110136005)(305945005)(105586002)(316002)(5660300001)(3846002)(256004)(39060400002)(68736007)(14454004)(1076002)(7736002)(76176011)(11346002)(2501003)(99286004)(52116002)(6116002)(4326008)(6512007)(53936002)(81166006)(81156014)(8936002)(102836004)(26005)(8676002)(186003)(14444005)(71190400001)(446003)(486006)(6436002)(86362001)(25786009)(6486002)(2616005)(386003)(476003)(478600001)(6506007)(71200400001); DIR:OUT; SFP:1102; SCL:1; SRVR:DM6PR01MB4601; H:DM6PR01MB4825.prod.exchangelabs.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:0; MX:1; received-spf: None (protection.outlook.com: os.amperecomputing.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: iun4RjmsT9X13tabTSV7CqUQEHqUz6Gndb2YFhLAzy7FpWRNoURTax5/qyJnkJEhmOVh7E47wyTOwo18E8XNf4TivUTKt60J6PeoZoaQpBgl1penQCR2Ji11L5pClzTokKL4tdAHUCnSBlJrQDftFF7uwpJlmshRY6qGmoh3GqouPLw56siJiTRgLjvKITt39usvgK4R+mX0Zt3Ld1iK/E8lhG77OmB9cYtZo2Va0bxbVMfDyXq4xQD9CLBvxM7UNwQ5PQw2LX6+S5L/eS2o3PV6vgp5DYHEdmHZpOjdPvXsVJjlZ6FMrOUuGTWACSWZ spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9a098bc7-7962-4401-b83d-08d65f7c3d18 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Dec 2018 15:20:52.8242 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR01MB4601 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.81.121 Subject: [Qemu-devel] [PATCH v10 13/14] target/arm: Implement PMSWINC 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: Aaron Lindsay , Michael Spradling , "qemu-devel@nongnu.org" , Digant Desai Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Aaron Lindsay Reviewed-by: Richard Henderson --- target/arm/helper.c | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index af09f757df..881d49c662 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -1027,6 +1027,15 @@ static bool event_always_supported(CPUARMState *env) return true; } +static uint64_t swinc_get_count(CPUARMState *env) +{ + /* + * SW_INCR events are written directly to the pmevcntr's by writes to + * PMSWINC, so there is no underlying count maintained by the PMU itself + */ + return 0; +} + /* * Return the underlying cycle count for the PMU cycle counters. If we're in * usermode, simply return 0. @@ -1054,6 +1063,10 @@ static uint64_t instructions_get_count(CPUARMState *env) #endif static const pm_event pm_events[] = { + { .number = 0x000, /* SW_INCR */ + .supported = event_always_supported, + .get_count = swinc_get_count, + }, #ifndef CONFIG_USER_ONLY { .number = 0x008, /* INST_RETIRED, Instruction architecturally executed */ .supported = instructions_supported, @@ -1393,6 +1406,24 @@ static void pmcr_write(CPUARMState *env, const ARMCPRegInfo *ri, pmu_op_finish(env); } +static void pmswinc_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + unsigned int i; + for (i = 0; i < pmu_num_counters(env); i++) { + /* Increment a counter's count iff: */ + if ((value & (1 << i)) && /* counter's bit is set */ + /* counter is enabled and not filtered */ + pmu_counter_enabled(env, i) && + /* counter is SW_INCR */ + (env->cp15.c14_pmevtyper[i] & PMXEVTYPER_EVTCOUNT) == 0x0) { + pmevcntr_op_start(env, i); + env->cp15.c14_pmevcntr[i]++; + pmevcntr_op_finish(env, i); + } + } +} + static uint64_t pmccntr_read(CPUARMState *env, const ARMCPRegInfo *ri) { uint64_t ret; @@ -1813,9 +1844,13 @@ static const ARMCPRegInfo v7_cp_reginfo[] = { .fieldoffset = offsetof(CPUARMState, cp15.c9_pmovsr), .writefn = pmovsr_write, .raw_writefn = raw_write }, - /* Unimplemented so WI. */ { .name = "PMSWINC", .cp = 15, .crn = 9, .crm = 12, .opc1 = 0, .opc2 = 4, - .access = PL0_W, .accessfn = pmreg_access_swinc, .type = ARM_CP_NOP }, + .access = PL0_W, .accessfn = pmreg_access_swinc, .type = ARM_CP_NO_RAW, + .writefn = pmswinc_write }, + { .name = "PMSWINC_EL0", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 3, .crn = 9, .crm = 12, .opc2 = 4, + .access = PL0_W, .accessfn = pmreg_access_swinc, .type = ARM_CP_NO_RAW, + .writefn = pmswinc_write }, { .name = "PMSELR", .cp = 15, .crn = 9, .crm = 12, .opc1 = 0, .opc2 = 5, .access = PL0_RW, .type = ARM_CP_ALIAS, .fieldoffset = offsetoflow32(CPUARMState, cp15.c9_pmselr),