From nobody Mon Feb 9 07:56:25 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1592341114; cv=none; d=zohomail.com; s=zohoarc; b=L5qsiD+3Jh23GOXI8Sd8Kw5WfjbVzVsJhFNDzQ2mk+65RKrdye+czl/gsV0KZcdamkVDD5aNNTkdyKGa9yaNnwxU7zS6aAiV2MpGa/tHtca+fKxQ5rCnAj2l8iNv3vpk9oRmaPBfwRUEcODjo2Nu4ZPzNDRuPD5euN1IcvGtYn8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592341114; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=r2cXx4B5tYUuz6vjelFc/8FkauY3IW78xwdK/FV/nUI=; b=JE64LQd2GH09kL1FFF2dWJ7uRv5kU+dRJ7jCb9hbXYrK1698QrfepKOjp+qJuvoEAaH5A01vqn0WJs6H+viYpwd79asssOnnPdBkvTqUpfE0SmJkA8gnGiY9DBL8g/j6rY4GKLWl1URlHLcEJqk+UsUwFb563Whdd5ZEf+BZneE= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592341114982465.3716729434651; Tue, 16 Jun 2020 13:58:34 -0700 (PDT) Received: from localhost ([::1]:50242 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlIfB-00056G-MR for importer@patchew.org; Tue, 16 Jun 2020 16:58:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33764) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlIeG-0003hI-0v for qemu-devel@nongnu.org; Tue, 16 Jun 2020 16:57:36 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:43502) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlIeE-0003Ee-9S for qemu-devel@nongnu.org; Tue, 16 Jun 2020 16:57:35 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 05GKmEd6012169 for ; Tue, 16 Jun 2020 16:57:33 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 31q23ne670-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 16 Jun 2020 16:57:33 -0400 Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 05GKmXSN013067 for ; Tue, 16 Jun 2020 16:57:32 -0400 Received: from ppma04dal.us.ibm.com (7a.29.35a9.ip4.static.sl-reverse.com [169.53.41.122]) by mx0a-001b2d01.pphosted.com with ESMTP id 31q23ne66q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 16 Jun 2020 16:57:32 -0400 Received: from pps.filterd (ppma04dal.us.ibm.com [127.0.0.1]) by ppma04dal.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 05GKsru9030034; Tue, 16 Jun 2020 20:57:31 GMT Received: from b03cxnp07029.gho.boulder.ibm.com (b03cxnp07029.gho.boulder.ibm.com [9.17.130.16]) by ppma04dal.us.ibm.com with ESMTP id 31mpe9gkuk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 16 Jun 2020 20:57:31 +0000 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 05GKvUwP61669878 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 16 Jun 2020 20:57:30 GMT Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 773F5C6057; Tue, 16 Jun 2020 20:57:30 +0000 (GMT) Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C0B87C605B; Tue, 16 Jun 2020 20:57:29 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP; Tue, 16 Jun 2020 20:57:29 +0000 (GMT) From: Stefan Berger To: qemu-devel@nongnu.org Subject: [PATCH v3 7/8] tpm: Guard irq related ops in case interrupts are disabled Date: Tue, 16 Jun 2020 16:57:20 -0400 Message-Id: <20200616205721.1191408-8-stefanb@linux.vnet.ibm.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200616205721.1191408-1-stefanb@linux.vnet.ibm.com> References: <20200616205721.1191408-1-stefanb@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216, 18.0.687 definitions=2020-06-16_12:2020-06-16, 2020-06-16 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 mlxscore=0 phishscore=0 spamscore=0 bulkscore=0 lowpriorityscore=0 adultscore=0 cotscore=-2147483648 malwarescore=0 mlxlogscore=955 suspectscore=1 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006160140 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=148.163.156.1; envelope-from=stefanb@linux.vnet.ibm.com; helo=mx0a-001b2d01.pphosted.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/16 16:57:28 X-ACL-Warn: Detected OS = Linux 3.x [generic] [fuzzy] X-Spam_score_int: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefan Berger , eric.auger@redhat.com, pbonzini@redhat.com, marcandre.lureau@redhat.com, philmd@redhat.com, mkedzier@redhat.com, Stefan Berger Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Check for irq_num having the value of TPM_IRQ_DISABLED before calling any IRQ related functions or allowing the user to try to enable interrupts. Explicitly allow the value of TPM_IRQ_DISABLED in irq_num. Signed-off-by: Stefan Berger --- hw/tpm/tpm_tis_common.c | 12 +++++++++++- hw/tpm/tpm_tis_isa.c | 6 ++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/hw/tpm/tpm_tis_common.c b/hw/tpm/tpm_tis_common.c index 0f42696f1f..13b233309e 100644 --- a/hw/tpm/tpm_tis_common.c +++ b/hw/tpm/tpm_tis_common.c @@ -359,7 +359,11 @@ static uint64_t tpm_tis_mmio_read(void *opaque, hwaddr= addr, val =3D s->loc[locty].inte; break; case TPM_TIS_REG_INT_VECTOR: - val =3D s->irq_num; + if (s->irq_num !=3D TPM_IRQ_DISABLED) { + val =3D s->irq_num; + } else { + val =3D 0; + } break; case TPM_TIS_REG_INT_STATUS: val =3D s->loc[locty].ints; @@ -591,6 +595,9 @@ static void tpm_tis_mmio_write(void *opaque, hwaddr add= r, if (s->active_locty !=3D locty) { break; } + if (s->irq_num =3D=3D TPM_IRQ_DISABLED) { + val &=3D ~TPM_TIS_INT_ENABLED; + } =20 s->loc[locty].inte &=3D mask; s->loc[locty].inte |=3D (val & (TPM_TIS_INT_ENABLED | @@ -601,6 +608,9 @@ static void tpm_tis_mmio_write(void *opaque, hwaddr add= r, /* hard wired -- ignore */ break; case TPM_TIS_REG_INT_STATUS: + if (s->irq_num =3D=3D TPM_IRQ_DISABLED) { + break; + } /* clearing of interrupt flags */ if (((val & TPM_TIS_INTERRUPTS_SUPPORTED)) && (s->loc[locty].ints & TPM_TIS_INTERRUPTS_SUPPORTED)) { diff --git a/hw/tpm/tpm_tis_isa.c b/hw/tpm/tpm_tis_isa.c index 27222a9a49..d72f733ead 100644 --- a/hw/tpm/tpm_tis_isa.c +++ b/hw/tpm/tpm_tis_isa.c @@ -127,13 +127,15 @@ static void tpm_tis_isa_realizefn(DeviceState *dev, E= rror **errp) error_setg(errp, "'tpmdev' property is required"); return; } - if (s->irq_num > 15) { + if (s->irq_num > 15 && s->irq_num !=3D TPM_IRQ_DISABLED) { error_setg(errp, "IRQ %d is outside valid range of 0 to 15", s->irq_num); return; } =20 - isa_init_irq(ISA_DEVICE(dev), &s->irq, s->irq_num); + if (s->irq_num !=3D TPM_IRQ_DISABLED) { + isa_init_irq(ISA_DEVICE(dev), &s->irq, s->irq_num); + } =20 memory_region_add_subregion(isa_address_space(ISA_DEVICE(dev)), TPM_TIS_ADDR_BASE, &s->mmio); --=20 2.24.1