From nobody Fri May 3 10:23:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1621530514; cv=none; d=zohomail.com; s=zohoarc; b=MAB5WB/3p/2gzQyXX3kWT0UBJnuaIXossOQCEHJyRCcrZW4cv3XriREQrE6LlmKdyjTBWYB364Erusu0vG9QmFpCzi6uINbiiL/gwUNmDmUs5qEWO3m4Zn8ft5grNxgcnzIlhoAF+h49uoHcPKVjPtu02OUK6ffnL8ka41Bms2g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621530514; h=Content-Type: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=5bvvQ+jCtf8ckhRg23/RTaEsh9OIQNq4YfyNz/nXjCw=; b=FQAB/7AZeDg/tVXDs92zmq1aSXR5F9sDFCRoasvTQPjWdowAwvEMCAwiSbWoErZXBtgh5sm0ywf9YOyWlflhLY6+XBVWGCxptFJK/DCgnF+kwABqlgyTbrvLZMadBJAXBTs931etR9Vk5qWumjXdQdO3ahU4XcTmB0TBXT+dod4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1621530514107810.418346099288; Thu, 20 May 2021 10:08:34 -0700 (PDT) Received: from localhost ([::1]:59712 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ljm9w-0007w5-IJ for importer2@patchew.org; Thu, 20 May 2021 13:08:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42854) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljm76-0001Mc-VO for qemu-devel@nongnu.org; Thu, 20 May 2021 13:05:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:60721) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljm75-0005a8-7y for qemu-devel@nongnu.org; Thu, 20 May 2021 13:05:36 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-154-z1Zf9IGuOMS-VCb2ixpjtA-1; Thu, 20 May 2021 13:05:32 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5B118107ACE3; Thu, 20 May 2021 17:05:31 +0000 (UTC) Received: from gondolin.fritz.box (ovpn-113-166.ams2.redhat.com [10.36.113.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 31FBF5D6D5; Thu, 20 May 2021 17:05:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621530334; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5bvvQ+jCtf8ckhRg23/RTaEsh9OIQNq4YfyNz/nXjCw=; b=Rl2zsEEtjrJ8AMCp8/RO42CBFQ/QBNLfwcKvuJ0JyRqdiOHo4BiS67M3+2pJGaszMQXeGX OqtsHwP5xlfVeSMbHPiHAwYT8OWkPPcODrDilhhhlqnm1y8RIJ3QSCy8QBmp1He2+lxPOt aH8ylQ6XuTfooIqRySjQP+3aF/dYhmA= X-MC-Unique: z1Zf9IGuOMS-VCb2ixpjtA-1 From: Cornelia Huck To: Peter Maydell Subject: [PULL v2 1/9] target/s390x: Fix translation exception on illegal instruction Date: Thu, 20 May 2021 19:05:11 +0200 Message-Id: <20210520170519.300951-2-cohuck@redhat.com> In-Reply-To: <20210520170519.300951-1-cohuck@redhat.com> References: <20210520170519.300951-1-cohuck@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=cohuck@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=cohuck@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.39, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Cornelia Huck , qemu-s390x@nongnu.org, David Hildenbrand , qemu-devel@nongnu.org, Ilya Leoshkevich Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Ilya Leoshkevich Hitting an uretprobe in a s390x TCG guest causes a SIGSEGV. What happens is: * uretprobe maps a userspace page containing an invalid instruction. * uretprobe replaces the target function's return address with the address of that page. * When tb_gen_code() is called on that page, tb->size ends up being 0 (because the page starts with the invalid instruction), which causes virt_page2 to point to the previous page. * The previous page is not mapped, so this causes a spurious translation exception. tb->size must never be 0: even if there is an illegal instruction, the instruction bytes that have been looked at must count towards tb->size. So adjust s390x's translate_one() to act this way for both illegal instructions and instructions that are known to generate exceptions. Signed-off-by: Ilya Leoshkevich Reviewed-by: David Hildenbrand Message-Id: <20210416154939.32404-2-iii@linux.ibm.com> Signed-off-by: Cornelia Huck --- target/s390x/translate.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/target/s390x/translate.c b/target/s390x/translate.c index 4f953ddfbaf6..e243624d2a62 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -6412,7 +6412,8 @@ static DisasJumpType translate_one(CPUS390XState *env= , DisasContext *s) qemu_log_mask(LOG_UNIMP, "unimplemented opcode 0x%02x%02x\n", s->fields.op, s->fields.op2); gen_illegal_opcode(s); - return DISAS_NORETURN; + ret =3D DISAS_NORETURN; + goto out; } =20 #ifndef CONFIG_USER_ONLY @@ -6428,7 +6429,8 @@ static DisasJumpType translate_one(CPUS390XState *env= , DisasContext *s) /* privileged instruction */ if ((s->base.tb->flags & FLAG_MASK_PSTATE) && (insn->flags & IF_PR= IV)) { gen_program_exception(s, PGM_PRIVILEGED); - return DISAS_NORETURN; + ret =3D DISAS_NORETURN; + goto out; } =20 /* if AFP is not enabled, instructions and registers are forbidden= */ @@ -6455,7 +6457,8 @@ static DisasJumpType translate_one(CPUS390XState *env= , DisasContext *s) } if (dxc) { gen_data_exception(dxc); - return DISAS_NORETURN; + ret =3D DISAS_NORETURN; + goto out; } } =20 @@ -6463,7 +6466,8 @@ static DisasJumpType translate_one(CPUS390XState *env= , DisasContext *s) if (insn->flags & IF_VEC) { if (!((s->base.tb->flags & FLAG_MASK_VECTOR))) { gen_data_exception(0xfe); - return DISAS_NORETURN; + ret =3D DISAS_NORETURN; + goto out; } } =20 @@ -6484,7 +6488,8 @@ static DisasJumpType translate_one(CPUS390XState *env= , DisasContext *s) (insn->spec & SPEC_r1_f128 && !is_fp_pair(get_field(s, r1))) || (insn->spec & SPEC_r2_f128 && !is_fp_pair(get_field(s, r2)))) { gen_program_exception(s, PGM_SPECIFICATION); - return DISAS_NORETURN; + ret =3D DISAS_NORETURN; + goto out; } } =20 @@ -6544,6 +6549,7 @@ static DisasJumpType translate_one(CPUS390XState *env= , DisasContext *s) } #endif =20 +out: /* Advance to the next instruction. */ s->base.pc_next =3D s->pc_tmp; return ret; --=20 2.31.1 From nobody Fri May 3 10:23:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1621530589; cv=none; d=zohomail.com; s=zohoarc; b=geGk4a5eLAyVsXkDQ77gJjMbK+JwDkORHnxkQbNM0z0+eoZpXw1DozodTiHH5JzA2lGOead/z+aaXmL1WlLUYVx0XMfvJzfWvtOJ/ljaESH8Mpr8Dw0dYx+QvqogiPNFGANOCrqw8HdorsnsiCD+t10J91R7PxzXx7TRwQyADng= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621530589; h=Content-Type: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=9eVSHhnlZ1XejkdF0IqqJB91nZk1tTrfzmjT7Kiy3ys=; b=BdawTbGZ/dfHjh+I77KXQhvJv8VBM0qkNA+Xc1SpbKvtug2u7sqCq6z6fSM63H4nL70FA5iszvzI6tiWl2Jvue91mjnAiJXJIHI1pd2BQkG0HbUzLEBvmQzxTyMM79tefs1Mm9yQbEHgTtkmbypj0nVSuifBJM60ARGt+LpL24s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1621530589060320.8174225760632; Thu, 20 May 2021 10:09:49 -0700 (PDT) Received: from localhost ([::1]:33720 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ljmBA-000121-0N for importer2@patchew.org; Thu, 20 May 2021 13:09:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42922) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljm7E-0001Ut-IZ for qemu-devel@nongnu.org; Thu, 20 May 2021 13:05:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:35332) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljm76-0005an-VM for qemu-devel@nongnu.org; Thu, 20 May 2021 13:05:41 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-347-VC4qglK0P1KiCoqGt1zvzg-1; Thu, 20 May 2021 13:05:34 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EF73D802575; Thu, 20 May 2021 17:05:32 +0000 (UTC) Received: from gondolin.fritz.box (ovpn-113-166.ams2.redhat.com [10.36.113.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id A5C5B5D6D5; Thu, 20 May 2021 17:05:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621530336; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9eVSHhnlZ1XejkdF0IqqJB91nZk1tTrfzmjT7Kiy3ys=; b=Bu0wIPBbGU3i678ZOj90jzK/3cQxryWuctxw7yfkQjklwGKqwpX4yPpc1hoHrTlpOr1fO8 MXUnbsJTHVmUTa1/NipFwuVBPr5uiNZoBk/Qdfv+C+CyaBkFE4GxcPnb1M7y1+BCxslV0Y eA4O4uJIJ6OgY6fMPnSpIlZKwN+p/GA= X-MC-Unique: VC4qglK0P1KiCoqGt1zvzg-1 From: Cornelia Huck To: Peter Maydell Subject: [PULL v2 2/9] target/arm: Make sure that commpage's tb->size != 0 Date: Thu, 20 May 2021 19:05:12 +0200 Message-Id: <20210520170519.300951-3-cohuck@redhat.com> In-Reply-To: <20210520170519.300951-1-cohuck@redhat.com> References: <20210520170519.300951-1-cohuck@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=cohuck@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=cohuck@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.39, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: qemu-s390x@nongnu.org, Cornelia Huck , Richard Henderson , qemu-devel@nongnu.org, Ilya Leoshkevich Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Ilya Leoshkevich tb_gen_code() assumes that tb->size must never be zero, otherwise it may produce spurious exceptions. For ARM this may happen when creating a translation block for the commpage. Fix by pretending that commpage translation blocks have at least one instruction. Signed-off-by: Ilya Leoshkevich Reviewed-by: Richard Henderson Message-Id: <20210416154939.32404-3-iii@linux.ibm.com> Signed-off-by: Cornelia Huck --- target/arm/translate.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/arm/translate.c b/target/arm/translate.c index 455352bcf60f..8e0e55c1e0f5 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -8981,6 +8981,7 @@ static void arm_tr_translate_insn(DisasContextBase *d= cbase, CPUState *cpu) unsigned int insn; =20 if (arm_pre_translate_insn(dc)) { + dc->base.pc_next +=3D 4; return; } =20 @@ -9050,6 +9051,7 @@ static void thumb_tr_translate_insn(DisasContextBase = *dcbase, CPUState *cpu) bool is_16bit; =20 if (arm_pre_translate_insn(dc)) { + dc->base.pc_next +=3D 2; return; } =20 --=20 2.31.1 From nobody Fri May 3 10:23:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1621530434; cv=none; d=zohomail.com; s=zohoarc; b=UukzfDtK21zUtKlvyPP6uSN5uX9uvW37g5mUYkXEwjJTYZdNqM3kkBSEuekayf7VmWwGwCo+qY1fe/vwpgRiBzTUalgNi/V4m/nL8Q6IM27uiAebgZHo0FJNrjTEzD5mq4nciibT7Tx7QRvSnmE4k45FTQNsFHnZW7KHu5M5C94= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621530434; h=Content-Type: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=g107d0hwMDuwWAJZE2QhIBSosIuw4vKnPSj9OwtVGoM=; b=FEzBtM/3qnUOrV6Bnb1vFFulvAQ6dA5cU8ngU7W1iO5cQ8hwG3bnUyfGcWEZs8qte7bSlHjc13w8vPt+WvQ5Hf7kBcrD7mOzFr7zZj26q7gz6Ty9xudrvHn8tMQXmhRFvpF5Tld8R4JAG8KsQPkmMQNuBiIf7OpxjzkEu7WB1w4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 162153043490475.53627031249243; Thu, 20 May 2021 10:07:14 -0700 (PDT) Received: from localhost ([::1]:54552 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ljm8f-0004Uu-Rb for importer2@patchew.org; Thu, 20 May 2021 13:07:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42958) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljm7I-0001Xv-Ec for qemu-devel@nongnu.org; Thu, 20 May 2021 13:05:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:47753) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljm7A-0005b4-04 for qemu-devel@nongnu.org; Thu, 20 May 2021 13:05:46 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-182-iDyfv5gbPSi_MI_lmad1Jw-1; Thu, 20 May 2021 13:05:35 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 976B41927800; Thu, 20 May 2021 17:05:34 +0000 (UTC) Received: from gondolin.fritz.box (ovpn-113-166.ams2.redhat.com [10.36.113.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 466555D6D5; Thu, 20 May 2021 17:05:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621530339; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g107d0hwMDuwWAJZE2QhIBSosIuw4vKnPSj9OwtVGoM=; b=VaNKC+ybfez8vqKdhJXneOITuVaVYoXxzaQZa0swIm9cXUMQztT8jFlHmDzM29vcIyCsmb iy+SoATf4IaYSnaTku+zYrirCGt+74Wr2bZEz0gBpT5iEV/K6BgJ4MEY4493JlxB0eJ5pD LQTP6QzQ+cpIFCLwPew2LTQeq+UszzI= X-MC-Unique: iDyfv5gbPSi_MI_lmad1Jw-1 From: Cornelia Huck To: Peter Maydell Subject: [PULL v2 3/9] target/xtensa: Make sure that tb->size != 0 Date: Thu, 20 May 2021 19:05:13 +0200 Message-Id: <20210520170519.300951-4-cohuck@redhat.com> In-Reply-To: <20210520170519.300951-1-cohuck@redhat.com> References: <20210520170519.300951-1-cohuck@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=cohuck@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=cohuck@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.39, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Max Filippov , qemu-s390x@nongnu.org, Cornelia Huck , qemu-devel@nongnu.org, Ilya Leoshkevich Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Ilya Leoshkevich tb_gen_code() assumes that tb->size must never be zero, otherwise it may produce spurious exceptions. For xtensa this may happen when decoding an unknown instruction, when handling a write into the CCOUNT or CCOMPARE special register and when single-stepping the first instruction of an exception handler. Fix by pretending that the size of the respective translation block is 1 in all these cases. Signed-off-by: Ilya Leoshkevich Tested-by: Max Filippov Acked-by: Max Filippov Message-Id: <20210416154939.32404-4-iii@linux.ibm.com> Signed-off-by: Cornelia Huck --- target/xtensa/translate.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c index 0ae4efc48a17..73584d9d605b 100644 --- a/target/xtensa/translate.c +++ b/target/xtensa/translate.c @@ -917,6 +917,7 @@ static void disas_xtensa_insn(CPUXtensaState *env, Disa= sContext *dc) "unknown instruction length (pc =3D %08x)\n", dc->pc); gen_exception_cause(dc, ILLEGAL_INSTRUCTION_CAUSE); + dc->base.pc_next =3D dc->pc + 1; return; } =20 @@ -1274,11 +1275,13 @@ static void xtensa_tr_translate_insn(DisasContextBa= se *dcbase, CPUState *cpu) if ((tb_cflags(dc->base.tb) & CF_USE_ICOUNT) && (dc->base.tb->flags & XTENSA_TBFLAG_YIELD)) { gen_exception(dc, EXCP_YIELD); + dc->base.pc_next =3D dc->pc + 1; dc->base.is_jmp =3D DISAS_NORETURN; return; } if (dc->base.tb->flags & XTENSA_TBFLAG_EXCEPTION) { gen_exception(dc, EXCP_DEBUG); + dc->base.pc_next =3D dc->pc + 1; dc->base.is_jmp =3D DISAS_NORETURN; return; } --=20 2.31.1 From nobody Fri May 3 10:23:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1621530433; cv=none; d=zohomail.com; s=zohoarc; b=GfzG8hhgJ2+u8xyzxnvavpoPQG56rG2AH0MS158Vhy9FbI6HANDoGgUl/TJFgFyiEKJhBzuQe0skzQQYcFvH2OSBZzkTmPVCKElktM4PHXcQ0Y/ybKvMChfJtDzuEAOPUilhYeg4gfbDj98b5WwnGrwqY3+yLlZxDXez9JCFLLs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621530433; h=Content-Type: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=e0SNQoAqdb4bl76wcRMsvUXYfkexwm35ttQDzweDdUk=; b=dmk7V5uuY8hOCYiUQdpLaig1JC+0+m0MU62GcdBrnaFid2KPQ41z87wHeL+JS0NAGYeIWtUTnZp4rwoac/78z+we8MhX746azJ8obnV319aWckDHWeUq15NVuzIa0Ci2WW6c+NJxMAwNKvrk8EAZjq0aFYJ2A6FjTPq2yawQvtY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1621530433933729.2813642682889; Thu, 20 May 2021 10:07:13 -0700 (PDT) Received: from localhost ([::1]:54490 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ljm8e-0004S6-SF for importer2@patchew.org; Thu, 20 May 2021 13:07:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43000) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljm7M-0001cN-AV for qemu-devel@nongnu.org; Thu, 20 May 2021 13:05:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:50060) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljm7B-0005cL-0Q for qemu-devel@nongnu.org; Thu, 20 May 2021 13:05:51 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-599-tbQBEVasNjuWj4k9eSfn9g-1; Thu, 20 May 2021 13:05:38 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3C7411020C38; Thu, 20 May 2021 17:05:36 +0000 (UTC) Received: from gondolin.fritz.box (ovpn-113-166.ams2.redhat.com [10.36.113.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id E2E4F5D6D5; Thu, 20 May 2021 17:05:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621530340; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=e0SNQoAqdb4bl76wcRMsvUXYfkexwm35ttQDzweDdUk=; b=WzEItpa/LNikurzXjuRQOinUTa7oXqOJ0oEGoBXCsBe6SE7UusSp3FHBtKz6LXcq5/NjBI mdCMv7sTgntk4uykpjhZG9fyV3ykvt/cx2KhsuVJxlrDHihypDmSwGhGq+7oBcfFKN5vvO Y2zxjOP7EL3TgS3F3+50XpwUd6Jwujw= X-MC-Unique: tbQBEVasNjuWj4k9eSfn9g-1 From: Cornelia Huck To: Peter Maydell Subject: [PULL v2 4/9] accel/tcg: Assert that tb->size != 0 after translation Date: Thu, 20 May 2021 19:05:14 +0200 Message-Id: <20210520170519.300951-5-cohuck@redhat.com> In-Reply-To: <20210520170519.300951-1-cohuck@redhat.com> References: <20210520170519.300951-1-cohuck@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=cohuck@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=cohuck@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.39, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cornelia Huck , qemu-s390x@nongnu.org, David Hildenbrand , qemu-devel@nongnu.org, Ilya Leoshkevich Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Ilya Leoshkevich If arch-specific code generates a translation block of size 0, tb_gen_code() may generate a spurious exception. Add an assertion in order to catch such situations early. Signed-off-by: Ilya Leoshkevich Reviewed-by: David Hildenbrand Message-Id: <20210416154939.32404-5-iii@linux.ibm.com> Signed-off-by: Cornelia Huck --- accel/tcg/translate-all.c | 1 + 1 file changed, 1 insertion(+) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index fbf8fc630b27..640ff6e3e706 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1912,6 +1912,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, =20 tcg_ctx->cpu =3D env_cpu(env); gen_intermediate_code(cpu, tb, max_insns); + assert(tb->size !=3D 0); tcg_ctx->cpu =3D NULL; max_insns =3D tb->icount; =20 --=20 2.31.1 From nobody Fri May 3 10:23:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1621530671; cv=none; d=zohomail.com; s=zohoarc; b=MgleJ/1N1N9bynZRIf1pE/J3b+ZEURTOFNJJ05ligNa4vJsQ7M9gZusmH20Ut/jBdTaeyyJXX5oUvGChyMa1QzEQ94lblxhkGNF0QEKk8VuywLPwC9Lr51XE6p68Lsng9pUOBCTtGHYsw6jXMK9w+q7uh+Lv44sSSkNH/g+XnvU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621530671; h=Content-Type: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=rbiqi95N3t0FvUT2LJ86516tFEPkNtui8jyogJ6FhZU=; b=Qy0OInWRt3r6KLo+Gg/u8YyLM8qPPBiU5J0LxhdCv1qtwbmGTOZHXLWnYUH+zXI2gEPMfYWvaHjqq6cLNeMYr0MBjtrujgsW6xyDl1mNzsNRoTPVOlloh97yum61pxdpsoHQEinKFOBxgbOed3CZ4a0J5/l+mPdfHvYcr0Leqks= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1621530671348226.50250628807942; Thu, 20 May 2021 10:11:11 -0700 (PDT) Received: from localhost ([::1]:39912 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ljmCU-0005Cx-CK for importer2@patchew.org; Thu, 20 May 2021 13:11:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43026) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljm7Q-0001lF-Cz for qemu-devel@nongnu.org; Thu, 20 May 2021 13:05:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:35947) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljm7C-0005cV-QH for qemu-devel@nongnu.org; Thu, 20 May 2021 13:05:56 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-331-Egqz84dQMPuk6jo6wJJKcQ-1; Thu, 20 May 2021 13:05:38 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AC79B1020C2E; Thu, 20 May 2021 17:05:37 +0000 (UTC) Received: from gondolin.fritz.box (ovpn-113-166.ams2.redhat.com [10.36.113.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8844D5D6D5; Thu, 20 May 2021 17:05:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621530341; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rbiqi95N3t0FvUT2LJ86516tFEPkNtui8jyogJ6FhZU=; b=b24hn0N8Pk3ZFMmlfydUqgOkcCipnqMykvCc9cz1Lqxu2C+QQluG6ae58qu8xsA2kbNaNJ G7uget0uIgduU4E1FBQtA7m0mZ4ZFneTPaQNOCqEh2B4T6/qhp7ez4GP5ubAT5uBsh34F/ KJAwivxS/MpVDmvdKw9juL3MWnMl3QY= X-MC-Unique: Egqz84dQMPuk6jo6wJJKcQ-1 From: Cornelia Huck To: Peter Maydell Subject: [PULL v2 5/9] vfio-ccw: Permit missing IRQs Date: Thu, 20 May 2021 19:05:15 +0200 Message-Id: <20210520170519.300951-6-cohuck@redhat.com> In-Reply-To: <20210520170519.300951-1-cohuck@redhat.com> References: <20210520170519.300951-1-cohuck@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=cohuck@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=cohuck@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.39, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eric Farman , qemu-s390x@nongnu.org, Cornelia Huck , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Eric Farman Commit 690e29b91102 ("vfio-ccw: Refactor ccw irq handler") changed one of the checks for the IRQ notifier registration from saying "the host needs to recognize the only IRQ that exists" to saying "the host needs to recognize ANY IRQ that exists." And this worked fine, because the subsequent change to support the CRW IRQ notifier doesn't get into this code when running on an older kernel, thanks to a guard by a capability region. The later addition of the REQ(uest) IRQ by commit b2f96f9e4f5f ("vfio-ccw: Connect the device request notifier") broke this assumption because there is no matching capability region. Thus, running new QEMU on an older kernel fails with: vfio: unexpected number of irqs 2 Let's adapt the message here so that there's a better clue of what IRQ is missing. Furthermore, let's make the REQ(uest) IRQ not fail when attempting to register it, to permit running vfio-ccw on a newer QEMU with an older kernel. Fixes: b2f96f9e4f5f ("vfio-ccw: Connect the device request notifier") Signed-off-by: Eric Farman Message-Id: <20210421152053.2379873-1-farman@linux.ibm.com> Signed-off-by: Cornelia Huck --- hw/vfio/ccw.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c index e752c845e9e4..7c058d13e8ce 100644 --- a/hw/vfio/ccw.c +++ b/hw/vfio/ccw.c @@ -411,8 +411,8 @@ static void vfio_ccw_register_irq_notifier(VFIOCCWDevic= e *vcdev, } =20 if (vdev->num_irqs < irq + 1) { - error_setg(errp, "vfio: unexpected number of irqs %u", - vdev->num_irqs); + error_setg(errp, "vfio: IRQ %u not available (number of irqs %u)", + irq, vdev->num_irqs); return; } =20 @@ -695,13 +695,15 @@ static void vfio_ccw_realize(DeviceState *dev, Error = **errp) =20 vfio_ccw_register_irq_notifier(vcdev, VFIO_CCW_REQ_IRQ_INDEX, &err); if (err) { - goto out_req_notifier_err; + /* + * Report this error, but do not make it a failing condition. + * Lack of this IRQ in the host does not prevent normal operation. + */ + error_report_err(err); } =20 return; =20 -out_req_notifier_err: - vfio_ccw_unregister_irq_notifier(vcdev, VFIO_CCW_CRW_IRQ_INDEX); out_crw_notifier_err: vfio_ccw_unregister_irq_notifier(vcdev, VFIO_CCW_IO_IRQ_INDEX); out_io_notifier_err: --=20 2.31.1 From nobody Fri May 3 10:23:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1621530599; cv=none; d=zohomail.com; s=zohoarc; b=a1R/eQnyjybgHiCZKHa42IP5ASvuwAu4Ji8c1hZeKsao2CtpJggKZqtqBqImpztT8XeNR4ynP8NpWSt2/shnHNbHLkVHEwJ/iZZ/7iVlK0uNCiwDr8wOojqiq6rPmD/PxysGhykFsmtC+59pYiCL3i784bwj9b/afXW+NcvLtTo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621530599; h=Content-Type: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=ogqVpnvzlF1m9BcTdNScdfDFhJYpB6ca/7EMi22uYrs=; b=BSHpy7D85xzEc+JvYSzvzMLxcVZ2TnNo+BBlcryzzE7aREYePLWCwI29kYKKU5gpO/6Md7KWHacV9kkQQX93Emx69zp9pbVZLG67bC2vsFK+x1E0Ho2hZBoWDUzwa2qis0sOKA/FGyunE5r9HZhCib0jLtFJuvQFDAgfgw+hjZs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 162153059987912.428221214599375; Thu, 20 May 2021 10:09:59 -0700 (PDT) Received: from localhost ([::1]:34942 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ljmBK-0001rK-Ob for importer2@patchew.org; Thu, 20 May 2021 13:09:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43006) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljm7M-0001dn-Pf for qemu-devel@nongnu.org; Thu, 20 May 2021 13:05:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:39392) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljm7E-0005cr-Bx for qemu-devel@nongnu.org; Thu, 20 May 2021 13:05:52 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-210-z3bMZinqNUaCgjvpC2IxaA-1; Thu, 20 May 2021 13:05:40 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 53F618030CF; Thu, 20 May 2021 17:05:39 +0000 (UTC) Received: from gondolin.fritz.box (ovpn-113-166.ams2.redhat.com [10.36.113.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 029CF5D6D5; Thu, 20 May 2021 17:05:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621530343; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ogqVpnvzlF1m9BcTdNScdfDFhJYpB6ca/7EMi22uYrs=; b=DIMiLs7u0d29LFwnFeDzsVdIeoCnSKHxGb9VMNyEeL322pZWuZfiKSMiKkSYkqS0tZbjVy Sw8qpYF+P0qk6EEJVjFGIHipmvzfBCs2H6ijIgMS7A2+INsRMh/1+3NzqodTEDRotSWf0R WvgmVovMHetOuKWHBmerHjwSMZrK7Yc= X-MC-Unique: z3bMZinqNUaCgjvpC2IxaA-1 From: Cornelia Huck To: Peter Maydell Subject: [PULL v2 6/9] hw/s390x/ccw: Register qbus type in abstract TYPE_CCW_DEVICE parent Date: Thu, 20 May 2021 19:05:16 +0200 Message-Id: <20210520170519.300951-7-cohuck@redhat.com> In-Reply-To: <20210520170519.300951-1-cohuck@redhat.com> References: <20210520170519.300951-1-cohuck@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=cohuck@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=cohuck@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.39, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: Eric Farman , qemu-s390x@nongnu.org, Cornelia Huck , qemu-devel@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 Instead of having all TYPE_CCW_DEVICE children set the bus type to TYPE_VIRTUAL_CSS_BUS, do it once in the abstract parent. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Acked-by: Eric Farman Message-Id: <20210424145313.3287400-1-f4bug@amsat.org> Signed-off-by: Cornelia Huck --- hw/s390x/3270-ccw.c | 1 - hw/s390x/ccw-device.c | 1 + hw/s390x/ccw-device.h | 1 + hw/s390x/s390-ccw.c | 2 -- hw/s390x/virtio-ccw.c | 1 - 5 files changed, 2 insertions(+), 4 deletions(-) diff --git a/hw/s390x/3270-ccw.c b/hw/s390x/3270-ccw.c index 25e628f57573..13e93d8d8f61 100644 --- a/hw/s390x/3270-ccw.c +++ b/hw/s390x/3270-ccw.c @@ -158,7 +158,6 @@ static void emulated_ccw_3270_class_init(ObjectClass *k= lass, void *data) DeviceClass *dc =3D DEVICE_CLASS(klass); =20 device_class_set_props(dc, emulated_ccw_3270_properties); - dc->bus_type =3D TYPE_VIRTUAL_CSS_BUS; dc->realize =3D emulated_ccw_3270_realize; dc->hotpluggable =3D false; set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories); diff --git a/hw/s390x/ccw-device.c b/hw/s390x/ccw-device.c index c9707110e9c8..95f269ab441e 100644 --- a/hw/s390x/ccw-device.c +++ b/hw/s390x/ccw-device.c @@ -59,6 +59,7 @@ static void ccw_device_class_init(ObjectClass *klass, voi= d *data) k->refill_ids =3D ccw_device_refill_ids; device_class_set_props(dc, ccw_device_properties); dc->reset =3D ccw_device_reset; + dc->bus_type =3D TYPE_VIRTUAL_CSS_BUS; } =20 const VMStateDescription vmstate_ccw_dev =3D { diff --git a/hw/s390x/ccw-device.h b/hw/s390x/ccw-device.h index 832c78cd4213..6dff95225df1 100644 --- a/hw/s390x/ccw-device.h +++ b/hw/s390x/ccw-device.h @@ -14,6 +14,7 @@ #include "qom/object.h" #include "hw/qdev-core.h" #include "hw/s390x/css.h" +#include "hw/s390x/css-bridge.h" =20 struct CcwDevice { DeviceState parent_obj; diff --git a/hw/s390x/s390-ccw.c b/hw/s390x/s390-ccw.c index 242491a1aea0..c227c77984ce 100644 --- a/hw/s390x/s390-ccw.c +++ b/hw/s390x/s390-ccw.c @@ -176,10 +176,8 @@ static void s390_ccw_instance_init(Object *obj) =20 static void s390_ccw_class_init(ObjectClass *klass, void *data) { - DeviceClass *dc =3D DEVICE_CLASS(klass); S390CCWDeviceClass *cdc =3D S390_CCW_DEVICE_CLASS(klass); =20 - dc->bus_type =3D TYPE_VIRTUAL_CSS_BUS; cdc->realize =3D s390_ccw_realize; cdc->unrealize =3D s390_ccw_unrealize; } diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index 92b950e09a13..220b9efcf945 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -1234,7 +1234,6 @@ static void virtio_ccw_device_class_init(ObjectClass = *klass, void *data) k->unplug =3D virtio_ccw_busdev_unplug; dc->realize =3D virtio_ccw_busdev_realize; dc->unrealize =3D virtio_ccw_busdev_unrealize; - dc->bus_type =3D TYPE_VIRTUAL_CSS_BUS; device_class_set_parent_reset(dc, virtio_ccw_reset, &vdc->parent_reset= ); } =20 --=20 2.31.1 From nobody Fri May 3 10:23:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1621530810; cv=none; d=zohomail.com; s=zohoarc; b=JHZ62nxLApYvvVgoH7hFY5JVWsuYmJcXZjVYjDO2cOtr9TUDp+gWAhbr2VE9x2I8yoAjgtd2LLbH97VQQMcrWPCn6Dra9FJej7FyGnUWLVqMDFg/7H9s9FgVXRt/wCfJLiTW4wysiC3JhMBLAEeAOgRPtHgCvFdGo3o5ZwBRBio= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621530810; h=Content-Type: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=CwF66TUVdEU4N2CNWmzN4Yai6fiOemufiFhmdTLXm+E=; b=j25cT2CGId7TkOMAQ+ll6aInj++4nuHDfWlJnCkurkm1VqapL9AcLbaz6KkZ9xT18KJL4Yofn2YyVIE2VnzMZfwfdp1UrtgoxkGQXMJ5Bz8esVZIlP9PM4LIvTcjfJotPhbH3mSJXYjSo0Ye7wxq+NEdW1nXfdCUtSSsyhdGJBU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1621530810667212.08300845700808; Thu, 20 May 2021 10:13:30 -0700 (PDT) Received: from localhost ([::1]:42600 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ljmEj-0007BO-Jw for importer2@patchew.org; Thu, 20 May 2021 13:13:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43080) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljm7S-0001qi-VQ for qemu-devel@nongnu.org; Thu, 20 May 2021 13:05:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:55242) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljm7G-0005eG-OA for qemu-devel@nongnu.org; Thu, 20 May 2021 13:05:58 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-426-i4iBpDDpMo6IBNK_whmn3A-1; Thu, 20 May 2021 13:05:42 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E9A20107ACCD; Thu, 20 May 2021 17:05:40 +0000 (UTC) Received: from gondolin.fritz.box (ovpn-113-166.ams2.redhat.com [10.36.113.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9EE3F5D6D5; Thu, 20 May 2021 17:05:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621530345; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CwF66TUVdEU4N2CNWmzN4Yai6fiOemufiFhmdTLXm+E=; b=fyy73p6tU2+l3xkoV52/UUumngt2alv7F9HlvC2X7Mpu3+VWqkyJ3oekg3KugP6TCH6NzG TiYOaQwD7UdvrDZXMxCpF8RC2guduJEWOeojdpTkTli5CaF79wC1kn+ncuo8/xIXEIUGPD 32UEAQo3DnoiUwDKNRdUe1N+7fjRXj0= X-MC-Unique: i4iBpDDpMo6IBNK_whmn3A-1 From: Cornelia Huck To: Peter Maydell Subject: [PULL v2 7/9] vfio-ccw: Attempt to clean up all IRQs on error Date: Thu, 20 May 2021 19:05:17 +0200 Message-Id: <20210520170519.300951-8-cohuck@redhat.com> In-Reply-To: <20210520170519.300951-1-cohuck@redhat.com> References: <20210520170519.300951-1-cohuck@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=cohuck@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=cohuck@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.39, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eric Farman , qemu-s390x@nongnu.org, Cornelia Huck , qemu-devel@nongnu.org, Matthew Rosato Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Eric Farman The vfio_ccw_unrealize() routine makes an unconditional attempt to unregister every IRQ notifier, though they may not have been registered in the first place (when running on an older kernel, for example). Let's mirror this behavior in the error cleanups in vfio_ccw_realize() so that if/when new IRQs are added, it is less confusing to recognize the necessary procedures. The worst case scenario would be some extra messages about an undefined IRQ, but since this is an error exit that won't be the only thing to worry about. And regarding those messages, let's change it to a warning instead of an error, to better reflect their severity. The existing code in both paths handles everything anyway. Signed-off-by: Eric Farman Acked-by: Matthew Rosato Message-Id: <20210428143652.1571487-1-farman@linux.ibm.com> Signed-off-by: Cornelia Huck --- hw/vfio/ccw.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c index 7c058d13e8ce..139a3d9d1b95 100644 --- a/hw/vfio/ccw.c +++ b/hw/vfio/ccw.c @@ -469,7 +469,7 @@ static void vfio_ccw_unregister_irq_notifier(VFIOCCWDev= ice *vcdev, =20 if (vfio_set_irq_signaling(&vcdev->vdev, irq, 0, VFIO_IRQ_SET_ACTION_TRIGGER, -1, &err)) { - error_reportf_err(err, VFIO_MSG_PREFIX, vcdev->vdev.name); + warn_reportf_err(err, VFIO_MSG_PREFIX, vcdev->vdev.name); } =20 qemu_set_fd_handler(event_notifier_get_fd(notifier), @@ -689,7 +689,7 @@ static void vfio_ccw_realize(DeviceState *dev, Error **= errp) if (vcdev->crw_region) { vfio_ccw_register_irq_notifier(vcdev, VFIO_CCW_CRW_IRQ_INDEX, &err= ); if (err) { - goto out_crw_notifier_err; + goto out_irq_notifier_err; } } =20 @@ -704,7 +704,9 @@ static void vfio_ccw_realize(DeviceState *dev, Error **= errp) =20 return; =20 -out_crw_notifier_err: +out_irq_notifier_err: + vfio_ccw_unregister_irq_notifier(vcdev, VFIO_CCW_REQ_IRQ_INDEX); + vfio_ccw_unregister_irq_notifier(vcdev, VFIO_CCW_CRW_IRQ_INDEX); vfio_ccw_unregister_irq_notifier(vcdev, VFIO_CCW_IO_IRQ_INDEX); out_io_notifier_err: vfio_ccw_put_region(vcdev); --=20 2.31.1 From nobody Fri May 3 10:23:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1621531239; cv=none; d=zohomail.com; s=zohoarc; b=htHyUieoV4o4AWua9BX3tKVqPL7sC/uGP6cVld/S4FIMGx64Q+kJBcVRqrkcVcxtXi34jdJ6a1JO8WYtlc7G3DAGGeLJRa0h56c6y+hd/+UJ2zEkeZ+rkDHPLo5W13ofRQclIwAQlxbfCS9GHNKsaLixFt7kMB6nFBnNZzHXrhE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621531239; h=Content-Type: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=gYbc/1vr0hl1H+rXHx7E2qRHbUcFCjELrIk1jhbNKuc=; b=c5SI1A7T1fVlcJjkY0wGTjFM/Bq6o68jPb53UhNuxCutHyl7N76hwhHtyx6JW+aIjzVfmUcPahhCiaX2Vwld9IdmKQEZxgJ1XGSbyWKGozXJa8A1BBKAT8wBPDqRPsQoatzA4SsGcXiQQCuNUcvrKZ1AZppc9Wocutf+58+/Qs4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1621531238964282.20523033747133; Thu, 20 May 2021 10:20:38 -0700 (PDT) Received: from localhost ([::1]:56304 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ljmLb-0000Nz-A1 for importer2@patchew.org; Thu, 20 May 2021 13:20:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43108) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljm7U-0001wp-Bi for qemu-devel@nongnu.org; Thu, 20 May 2021 13:06:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:39733) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljm7J-0005en-Bx for qemu-devel@nongnu.org; Thu, 20 May 2021 13:06:00 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-195-iZHqq2QJPPC2AYAWDQ67hw-1; Thu, 20 May 2021 13:05:44 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8B5961927801; Thu, 20 May 2021 17:05:42 +0000 (UTC) Received: from gondolin.fritz.box (ovpn-113-166.ams2.redhat.com [10.36.113.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id 40C085D6D5; Thu, 20 May 2021 17:05:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621530348; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gYbc/1vr0hl1H+rXHx7E2qRHbUcFCjELrIk1jhbNKuc=; b=aO/gJpQQhSjt844ypjBrW92fyH0Oqc4Cd7k5I448RwNxWhmuAqExqcnCvVXFzkv6CmBnED suy2MNn84tsDoLkOovj0cUwy/c05etnhWOrbqS/6GM6xB0ZilBt/uFy/k88JgPTvRE+FiD 8CJfEyNm2fHhFU9CM1ubtQxG6yRGxHM= X-MC-Unique: iZHqq2QJPPC2AYAWDQ67hw-1 From: Cornelia Huck To: Peter Maydell Subject: [PULL v2 8/9] target/i386: Make sure that vsyscall's tb->size != 0 Date: Thu, 20 May 2021 19:05:18 +0200 Message-Id: <20210520170519.300951-9-cohuck@redhat.com> In-Reply-To: <20210520170519.300951-1-cohuck@redhat.com> References: <20210520170519.300951-1-cohuck@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=cohuck@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=cohuck@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.39, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-s390x@nongnu.org, Cornelia Huck , Richard Henderson , qemu-devel@nongnu.org, Ilya Leoshkevich Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Ilya Leoshkevich tb_gen_code() assumes that tb->size must never be zero, otherwise it may produce spurious exceptions. For x86_64 this may happen when creating a translation block for the vsyscall page. Fix by pretending that vsyscall translation blocks have at least one instruction. Signed-off-by: Ilya Leoshkevich Reviewed-by: Richard Henderson Message-Id: <20210519045738.1335210-2-iii@linux.ibm.com> Signed-off-by: Cornelia Huck --- target/i386/tcg/translate.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index db56a483435d..3ab8c2385560 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -8583,6 +8583,7 @@ static void i386_tr_translate_insn(DisasContextBase *= dcbase, CPUState *cpu) */ if ((dc->base.pc_next & TARGET_PAGE_MASK) =3D=3D TARGET_VSYSCALL_PAGE)= { gen_exception(dc, EXCP_VSYSCALL, dc->base.pc_next); + dc->base.pc_next =3D dc->pc + 1; return; } #endif --=20 2.31.1 From nobody Fri May 3 10:23:03 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1621531054; cv=none; d=zohomail.com; s=zohoarc; b=Ioj2SocJQZvTeyIrdlQkYcgVnSGxX0ejUzpmF8lFep5Kj51K51T9wkvYFfVPBIZi5WJoGsIUs5FRXW4oF7EJv6l/JmgWyMJIMkrA8ryoHq+LOs9i84GfG1EQKo5UWsVYOHlLdntudhtTT1eoYhdOMybbnvrYXCziBzZcMWR3Otc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621531054; h=Content-Type: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=pdOZcruB1pNkMCesftF2wj8eJkVMil4kQmgcUFP93NY=; b=PDW3kwYRBrdERua8Ke4WAGPMU5OEq7tNmoN1zQRPF6BiYlBistTxeBYWgkOrspTFkAD3z7KkvVLgIRSBM3i11cqYBw2yKP5W8mMLeNZPx1Fmyyfx+QdQLuwcKxB8yYVDfYnM41RHQT2sChvix0N6U8K0O2i0cCVLRt22VCVLng0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1621531054295518.5314677161052; Thu, 20 May 2021 10:17:34 -0700 (PDT) Received: from localhost ([::1]:48908 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ljmIf-0003Mt-7h for importer2@patchew.org; Thu, 20 May 2021 13:17:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43110) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljm7U-0001wr-Da for qemu-devel@nongnu.org; Thu, 20 May 2021 13:06:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:35990) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljm7K-0005fh-2N for qemu-devel@nongnu.org; Thu, 20 May 2021 13:06:00 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-175-1g8xtBAEMC6K7PHXDM8KIg-1; Thu, 20 May 2021 13:05:45 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2DEA61E560; Thu, 20 May 2021 17:05:44 +0000 (UTC) Received: from gondolin.fritz.box (ovpn-113-166.ams2.redhat.com [10.36.113.166]) by smtp.corp.redhat.com (Postfix) with ESMTP id D66DC5D6D5; Thu, 20 May 2021 17:05:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621530349; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pdOZcruB1pNkMCesftF2wj8eJkVMil4kQmgcUFP93NY=; b=O1FDF8T6+YkJcfc8QyQN1CKNj61gXsA/8HIAD3t3P8J5wjUW5getNITAVOX4tUl6MWRddZ wPC/CZaO9DC7HlH4OdslP78AhsYmWq/siKtD2rxqnZT54HiWOyWl2FeiKbJF3tfz0cKeSt NLJZ0eSGgKurMZzXtoghFHbnOsSP4Bk= X-MC-Unique: 1g8xtBAEMC6K7PHXDM8KIg-1 From: Cornelia Huck To: Peter Maydell Subject: [PULL v2 9/9] tests/tcg/x86_64: add vsyscall smoke test Date: Thu, 20 May 2021 19:05:19 +0200 Message-Id: <20210520170519.300951-10-cohuck@redhat.com> In-Reply-To: <20210520170519.300951-1-cohuck@redhat.com> References: <20210520170519.300951-1-cohuck@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=cohuck@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=cohuck@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.39, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-s390x@nongnu.org, Cornelia Huck , Richard Henderson , qemu-devel@nongnu.org, Ilya Leoshkevich Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Ilya Leoshkevich Having a small test will prevent trivial regressions in the future. Signed-off-by: Ilya Leoshkevich Message-Id: <20210519045738.1335210-3-iii@linux.ibm.com> Reviewed-by: Richard Henderson Signed-off-by: Cornelia Huck --- tests/tcg/x86_64/Makefile.target | 6 +++++- tests/tcg/x86_64/vsyscall.c | 12 ++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 tests/tcg/x86_64/vsyscall.c diff --git a/tests/tcg/x86_64/Makefile.target b/tests/tcg/x86_64/Makefile.t= arget index 20bf96202ad2..2151ea6302ec 100644 --- a/tests/tcg/x86_64/Makefile.target +++ b/tests/tcg/x86_64/Makefile.target @@ -3,14 +3,18 @@ # x86_64 tests - included from tests/tcg/Makefile.target # # Currently we only build test-x86_64 and test-i386-ssse3 from -# $(SRC)/tests/tcg/i386/ +# $(SRC_PATH)/tests/tcg/i386/ # =20 include $(SRC_PATH)/tests/tcg/i386/Makefile.target =20 +X86_64_TESTS +=3D vsyscall TESTS=3D$(MULTIARCH_TESTS) $(X86_64_TESTS) test-x86_64 QEMU_OPTS +=3D -cpu max =20 test-x86_64: LDFLAGS+=3D-lm -lc test-x86_64: test-i386.c test-i386.h test-i386-shift.h test-i386-muldiv.h $(CC) $(CFLAGS) $< -o $@ $(LDFLAGS) + +vsyscall: $(SRC_PATH)/tests/tcg/x86_64/vsyscall.c + $(CC) $(CFLAGS) $< -o $@ $(LDFLAGS) diff --git a/tests/tcg/x86_64/vsyscall.c b/tests/tcg/x86_64/vsyscall.c new file mode 100644 index 000000000000..786b047053aa --- /dev/null +++ b/tests/tcg/x86_64/vsyscall.c @@ -0,0 +1,12 @@ +#include +#include + +#define VSYSCALL_PAGE 0xffffffffff600000 +#define TIME_OFFSET 0x400 +typedef time_t (*time_func)(time_t *); + +int main(void) +{ + printf("%ld\n", ((time_func)(VSYSCALL_PAGE + TIME_OFFSET))(NULL)); + return 0; +} --=20 2.31.1