From patchwork Thu Jun 22 11:18:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 106199 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp58311qgd; Thu, 22 Jun 2017 04:19:28 -0700 (PDT) X-Received: by 10.200.43.168 with SMTP id m37mr2041884qtm.228.1498130368448; Thu, 22 Jun 2017 04:19:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498130368; cv=none; d=google.com; s=arc-20160816; b=YgnfDMKoDX+tZYCX4Rv4tZA0/S5ywRJ+UkrnzHAARQujncPdchyI9xQX02rIq/FVm0 0woHNjAuicoJtJ8Zo+uUFViV0bkyu+oUAP+JnWmVe+2gKmmk6Cx8NP4b7n687FHeDc66 6MQbB3Vlxd6/3kWYJ4T8fl2xO8rjPIhqVjZky+3ro1ElBV06s1fkOLFuoga+exkaoMwD OZWj4DEjQ1DlxzxKmAoUT4+4+Rco9e5nlIgEPCxxGLQqBtjLBtbfZRKyFEcIp+kcw6rr YrjrW8owpjruW74LDAjjcnslWYpp1abEwQkQx9Y4Os84x7lpkEQ/gE1wUeJxSJ5/MKdt gF/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:message-id:date:to:from :dkim-signature:arc-authentication-results; bh=w1pnkHAfwflIpoJE09hh+JQ6kiSHDFm6oWFVCvqSzcQ=; b=PievCNd0RyYYZGEyx35sgHlpw5mGVp43oO90rZkqXnk18EtS1NjYnQ5+U74hcmszTO yfSEhtDUPmCqI0TSB4Ze4HwDy4fEJB3Q3TnIN1GkImT/1EW8ABSeYDdZD0ynKZTRezYf JmTrudwEb9EM5tDU51ZKBbp9RDhIbqUzb/yLZ9nMkJgsoeEh9hFs/W0zanUsuK49X4wn c8sK2BTpflgNbqR1FHxoTDJAFDY4g630SljmZNlyzeoDcwh4PKgoxUFZQ4mV9FPUQbYe fRl16ruWv4eZWaiJNP+5yhv4SGQw+NYnPhCBLvj+fiS2wcoAkAqszpx032diOwgdAzJs 1sLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.b=iktZxhIr; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m84si1199808qkh.57.2017.06.22.04.19.28 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 22 Jun 2017 04:19:28 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.b=iktZxhIr; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:58317 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dO090-0001SK-A0 for patch@linaro.org; Thu, 22 Jun 2017 07:19:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54651) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dO07s-0000aN-8z for qemu-devel@nongnu.org; Thu, 22 Jun 2017 07:18:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dO07p-0005Hu-0H for qemu-devel@nongnu.org; Thu, 22 Jun 2017 07:18:16 -0400 Received: from mail-wr0-x22e.google.com ([2a00:1450:400c:c0c::22e]:36074) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dO07o-0005HA-OC for qemu-devel@nongnu.org; Thu, 22 Jun 2017 07:18:12 -0400 Received: by mail-wr0-x22e.google.com with SMTP id c11so18856410wrc.3 for ; Thu, 22 Jun 2017 04:18:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=w1pnkHAfwflIpoJE09hh+JQ6kiSHDFm6oWFVCvqSzcQ=; b=iktZxhIrB011hnrTC4fWdTxrBmCwQBatyUqMYOoEmj+qx38Id2phlf+Nv0O99KMhMF man56YeYcy+CEtwKA9D45j3z3KMM1kXmbF9QnKQx1xdgKgbIEgd3RnBYYmEZin7J/Vor H/C+UJApr3rYAArOLXspcHKvIkBrSgY8leHDY= 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:mime-version :content-transfer-encoding; bh=w1pnkHAfwflIpoJE09hh+JQ6kiSHDFm6oWFVCvqSzcQ=; b=oRAmgVqwCwwAhxhDvJWBYbfwrRtEHf+bZZRYpTseIrFkmHUtYKMY5p3eCY2xxFrufl Hkj5CqLyqw4I+oFns/dntxnOS+Hlm6yhruTMqTS/YynUf8avNi/eaE/OUZXu4gtX0DI0 0HWNhlLkaU0GagI96iVGHF8YbP82MDAd+QjJoljIanBiP1Ae7ta/k2ZFxNjkAB8mXGYu 7ym3osqTvbr5wqD5Sryr8+XSE9ckfW8tYXjD6HZaDypXrM2vKZ8Tq+iNxDCWFAbRiKVb F3XS7o6zBcUNqDPf7XxCbgaZb8sS5f/6tpIvLNltuuri4slWkAT5Jp/JWiLQo1lUn6wA qNUw== X-Gm-Message-State: AKS2vOwjd5TFTfHRib4tTElyd/N34h/YsUbb/YwHdNTVaed4Rr2IUv9m efM6W7p+x0KsfTOj X-Received: by 10.28.156.17 with SMTP id f17mr1363635wme.17.1498130291233; Thu, 22 Jun 2017 04:18:11 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id q143sm1037423wmg.14.2017.06.22.04.18.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Jun 2017 04:18:10 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 7BECC3E0201; Thu, 22 Jun 2017 12:18:55 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Thu, 22 Jun 2017 12:18:45 +0100 Message-Id: <20170622111845.5296-1-alex.bennee@linaro.org> X-Mailer: git-send-email 2.13.0 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22e Subject: [Qemu-devel] [PATCH] target/arm/helper: document potential CNTV register bear trap 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: Andre Przywara , qemu-arm@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org, Christoffer Dall Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The ARM KVM encodings have been inadvertently switched for CNTV_CVAL_EL0/CNTVCT_EL0 in the register API since its introduction. Fortunately this doesn't currently mater as the reset values for both are the same. However if this ever changes things will break in interesting ways. Migration is currently unaffected as we just use cpu->cpreg_vmstate_indexes/cpreg_vmstate_values verbatim. However this would break if we ever supported migration between KVM and TCG models. For now we just warn future generations who may touch this code. Signed-off-by: Alex Bennée Cc: Andre Przywara Cc: Christoffer Dall --- target/arm/helper.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) -- 2.13.0 diff --git a/target/arm/helper.c b/target/arm/helper.c index 2594faa9b8..e7a0e39583 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -211,6 +211,11 @@ static bool raw_accessors_invalid(const ARMCPRegInfo *ri) return true; } +/* + * FIXME: the KVM API has switched encodings for + * CNTV_CVAL_EL0/CNTVCT_EL0 which need to be fixed if we want to + * change the reset values or support KVM<->TCG migration. + */ bool write_cpustate_to_list(ARMCPU *cpu) { /* Write the coprocessor state from cpu->env to the (index,value) list. */ @@ -234,6 +239,7 @@ bool write_cpustate_to_list(ARMCPU *cpu) return ok; } +/* FIXME: see above re:CNTV_CVAL_EL0/CNTVCT_EL0 encodings */ bool write_list_to_cpustate(ARMCPU *cpu) { int i; @@ -1961,6 +1967,11 @@ static const ARMCPRegInfo generic_timer_cp_reginfo[] = { cp15.c14_timer[GTIMER_VIRT].ctl), .writefn = gt_virt_ctl_write, .raw_writefn = raw_write, }, + /* WARNING! For *KVM only* the switched API encoding means this + * actually gets loaded in fresh VMs as CNTV_CVAL_EL0. This will + * need to be fixed in write_[cpustate_to_list|list_to_cpustate] + * if you want to change the reset value. + */ { .name = "CNTV_CTL_EL0", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 3, .crn = 14, .crm = 3, .opc2 = 1, .type = ARM_CP_IO, .access = PL1_RW | PL0_R, @@ -2053,6 +2064,11 @@ static const ARMCPRegInfo generic_timer_cp_reginfo[] = { .accessfn = gt_vtimer_access, .writefn = gt_virt_cval_write, .raw_writefn = raw_write, }, + /* WARNING! For *KVM only* the switched API encoding means this + * actually gets loaded in fresh VMs as CNTVCT_EL0. This will need + * to be fixed in write_[cpustate_to_list|list_to_cpustate] if you + * want to change the reset value. + */ { .name = "CNTV_CVAL_EL0", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 3, .crn = 14, .crm = 3, .opc2 = 2, .access = PL1_RW | PL0_R,