From patchwork Fri Nov 11 14:55:29 2022 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: 623745 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp828072pvb; Fri, 11 Nov 2022 06:58:20 -0800 (PST) X-Google-Smtp-Source: AA0mqf7b7Qlt3v8tAK4mrfKWMtSz379oS06Cb6Wcnd8BJNF3P3XBAHTRQxKCt/Tqelj5bdyspzoE X-Received: by 2002:a05:6214:5913:b0:4bb:59c1:3ded with SMTP id lp19-20020a056214591300b004bb59c13dedmr2222841qvb.68.1668178700406; Fri, 11 Nov 2022 06:58:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668178700; cv=none; d=google.com; s=arc-20160816; b=OhB/JnjoY91xmPOHKSG8FLwyi0bn3ssuEMwsQ22rxweG87e8HXLXOhH/QVxVpwdBtq BFnvbLmRBZHrbc/rvGB1kDcNR6ikOuRU0wcLIbgga5/MJKt+s8mEfr9vgYl1nLYOfgPk MrCTj9S0CpA+xiulWpnWSpf7sUuKuOG7CFlJs9Tw/AZ4kxdZ4774dV4BztopCcT2EHg1 4HN7TotRNcLiy22kCvg4M6AILxparrhb7YfnmM8e4K/cOyqPnFHBu3wx54m857ZXUdCe 1KSWch4G0bTDucTm4fbrdMY68fwf+OZajg1oUh+9UFhe4AWijWMwmpGLibn6i5fNkgQB 7oUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3w4mX1qsjSiPO0pJ/lfZfSTSL+aAl8Bv1zC1N3BSyI8=; b=YSoVMef2PWX8lJugrZios7ctTTdc3/oitvh3SmD3rWenBT6IjSonjvxdqHnalHLgR8 lIWfY51gBeVvoIz8MaJCk4SYeMn+Azo4vNqEn6o5VUYg8VWBCQe2PCFb6t8gzUCvfe5i qZF9oo7P9DuLhxBjJrutk9/ouMVXmIIvSDCNJUr2IZSfO/lgwJX+NlIJFUENhJvbJX58 lJ/VBHS7Dca1O98c4yueHV+RYRhfKajtRKx/WFwncPWK9Mkuw++zl+az+q+7NxyFZqRa Sm89hbf4egtqayxv/XxVq8MpzQn7SPUv5E2l7bKAcxP6khxGMC/iCWKiqvNcKxvfKIY+ a6RA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fMTvIFFD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id gh9-20020a05621429c900b004b9e3d82eb6si1010770qvb.161.2022.11.11.06.58.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 11 Nov 2022 06:58:20 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fMTvIFFD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1otVRa-00074i-P0; Fri, 11 Nov 2022 09:55:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1otVRZ-00073c-Dz for qemu-devel@nongnu.org; Fri, 11 Nov 2022 09:55:45 -0500 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1otVRW-0007yP-KT for qemu-devel@nongnu.org; Fri, 11 Nov 2022 09:55:45 -0500 Received: by mail-wr1-x434.google.com with SMTP id l14so6808453wrw.2 for ; Fri, 11 Nov 2022 06:55:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3w4mX1qsjSiPO0pJ/lfZfSTSL+aAl8Bv1zC1N3BSyI8=; b=fMTvIFFDCorfBpb/boI/HoBjuSOj1lrwBEdBgCRLf/iRw1+F//eR6oStfvCoMXWMnG nO/yAOIb6SctuwUgcLfA2mF1qJZRxigh1NCFKiO2iFYHxW+lvNJwNFbJ2uJ6jSXJwXt2 4daJd8KEHWXYfZ4YIRQoQBYlUEQRtSt+vgdlksKrwDiz7XDvGba3/K1BMR8qofMCu6yV 19jbbF8xMRPhLYcLGyXv5/LTBs4HsDeu3Z/4v6ypdy99BJ3aHZYa6aC270leKVO40Sli cx2RPyvkLN8tRQAZ+Hu2009uUzn2yFJacOvQJkIXZAE3IMj0NaFW/apUtIuU1gV28Hpx XIQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3w4mX1qsjSiPO0pJ/lfZfSTSL+aAl8Bv1zC1N3BSyI8=; b=oQBeVnmCtf/mmWDTJgOt8FjXMjiRv9CEyAFkzYRIJ9yHFfiaGU5wlujlJAXBPYJYkU 6ce0kYSGtkpO6RUWAJjoxK778ovMHlZPHZ/MKjmjhd09sINoNxjQ3fMxZnVduxKSD0Mo OJO1oMaqlDbuLhozYGSmjuhzwjO1yGN/rZhI+sUhdiUNoed/F3vDVUBrBIanUUEGKqmD QtprJ9kkkiJSkLz6RRmaQYR0w0Jtp0b3XC6gmv4JIGqB5T5alHlzdqHv6PzIXIzq4Xwq GA81ArSwSFSccVCnlpHiQV2GUVsCd6KepWg4gTH0SGanKOGM0P02Uzq6Oudt/x3meQH5 cPyg== X-Gm-Message-State: ANoB5pkj4SPSgaxHjtYyvcQ8B537J43ayp9IcJky1wdmCt4hPFVIvKIV +CCyXLy6octubiNFrPKjHFpvPQ== X-Received: by 2002:adf:e70c:0:b0:236:6578:48ad with SMTP id c12-20020adfe70c000000b00236657848admr1472896wrm.405.1668178541326; Fri, 11 Nov 2022 06:55:41 -0800 (PST) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id n19-20020a05600c3b9300b003b4c979e6bcsm9831705wms.10.2022.11.11.06.55.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Nov 2022 06:55:38 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 26F421FFC4; Fri, 11 Nov 2022 14:55:31 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: fam@euphon.net, berrange@redhat.com, f4bug@amsat.org, aurelien@aurel32.net, pbonzini@redhat.com, stefanha@redhat.com, crosa@redhat.com, =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Maydell , qemu-arm@nongnu.org (open list:ARM cores) Subject: [PATCH v2 12/12] hw/intc: add implementation of GICD_IIDR to Arm GIC Date: Fri, 11 Nov 2022 14:55:29 +0000 Message-Id: <20221111145529.4020801-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221111145529.4020801-1-alex.bennee@linaro.org> References: <20221111145529.4020801-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org a66a24585f (hw/intc/arm_gic: Implement read of GICC_IIDR) implemented this for the CPU interface register. The fact we don't implement it shows up when running Xen with -d guest_error which is definitely wrong because the guest is perfectly entitled to read it. Lightly re-factor this region of registers and also add a comment to the function in case anyway was under the illusion we only return bytes from a function called readb. Signed-off-by: Alex Bennée --- v2 - checkpatch fixes. --- hw/intc/arm_gic.c | 44 ++++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c index 492b2421ab..65b1ef7151 100644 --- a/hw/intc/arm_gic.c +++ b/hw/intc/arm_gic.c @@ -941,6 +941,10 @@ static void gic_complete_irq(GICState *s, int cpu, int irq, MemTxAttrs attrs) gic_update(s); } +/* + * Although this is named a byte read we don't always return bytes and + * rely on the calling function oring bits together. + */ static uint32_t gic_dist_readb(void *opaque, hwaddr offset, MemTxAttrs attrs) { GICState *s = (GICState *)opaque; @@ -954,23 +958,35 @@ static uint32_t gic_dist_readb(void *opaque, hwaddr offset, MemTxAttrs attrs) cpu = gic_get_current_cpu(s); cm = 1 << cpu; if (offset < 0x100) { - if (offset == 0) { /* GICD_CTLR */ - if (s->security_extn && !attrs.secure) { - /* The NS bank of this register is just an alias of the - * EnableGrp1 bit in the S bank version. - */ - return extract32(s->ctlr, 1, 1); - } else { - return s->ctlr; + if (offset < 0xc) { + switch (offset) { + case 0: /* GICD_CTLR[7:0] */ + { + if (s->security_extn && !attrs.secure) { + /* + * The NS bank of this register is just an alias of the + * EnableGrp1 bit in the S bank version. + */ + return extract32(s->ctlr, 1, 1); + } else { + return s->ctlr; + } } - } - if (offset == 4) - /* Interrupt Controller Type Register */ - return ((s->num_irq / 32) - 1) + case 4: /* GIC_TYPER - Interrupt Controller Type Register */ + { + return ((s->num_irq / 32) - 1) | ((s->num_cpu - 1) << 5) | (s->security_extn << 10); - if (offset < 0x08) - return 0; + } + case 8: /* GICD_IIDR - Implementer ID Register */ + { + return 0x43b; /* Arm JEP106 identity */ + } + default: + /* return 0 for high bits of above */ + return 0; + } + } if (offset >= 0x80) { /* Interrupt Group Registers: these RAZ/WI if this is an NS * access to a GIC with the security extensions, or if the GIC