From patchwork Wed Nov 4 17:25:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 318593 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8DAABC4741F for ; Wed, 4 Nov 2020 17:26:46 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F09FC2067C for ; Wed, 4 Nov 2020 17:26:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Tj2A9Qj7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F09FC2067C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:50266 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaMYW-0002S6-TD for qemu-devel@archiver.kernel.org; Wed, 04 Nov 2020 12:26:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60806) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaMXD-0000yB-4U for qemu-devel@nongnu.org; Wed, 04 Nov 2020 12:25:23 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:52398) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaMXA-00089x-T0 for qemu-devel@nongnu.org; Wed, 04 Nov 2020 12:25:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604510718; 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=GSqVm/KgbrzU6qODZkZODJ8w9yZNykzM/TsBNSVpeWk=; b=Tj2A9Qj7R+JKAiUY4JgPvOnRjcqqkrIFlvmCg2PJ4LjYYz4ysBhQHm7iTidq1brwxTAkMC fJO8AIBxvuLBXHN8mWGkB4dI5/kjN235IP1X8+L6ZISicha8+51Kr952Lk8hdD1oKrwLDy Fv42g4qXsGcmUq6mskng+mDg8TnnI8Y= 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-59-XsdCSUo2O4Wk_pKIXQigbg-1; Wed, 04 Nov 2020 12:25:17 -0500 X-MC-Unique: XsdCSUo2O4Wk_pKIXQigbg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 04B031028D41; Wed, 4 Nov 2020 17:25:16 +0000 (UTC) Received: from localhost (ovpn-114-68.rdu2.redhat.com [10.10.114.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id BD11A508E9; Wed, 4 Nov 2020 17:25:15 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Subject: [PATCH 1/7] sparc: Fix property/field size mismatch for iu-version Date: Wed, 4 Nov 2020 12:25:06 -0500 Message-Id: <20201104172512.2381656-2-ehabkost@redhat.com> In-Reply-To: <20201104172512.2381656-1-ehabkost@redhat.com> References: <20201104172512.2381656-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: Igor Mammedov , Mark Cave-Ayland , "Daniel P. Berrange" , Artyom Tarasenko , Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The "iu-version" property is declared as uint64_t but points to a target_ulong struct field. On the sparc 32-bit target, This makes every write of iu-version corrupt the 4 bytes after sparc_def_t.iu_version (where the fpu_version field is located). Change the type of the iu_version struct field to uint64_t, and just use DEFINE_PROP_UINT64. The only place where env.def.iu_version field is read is the env->version = env->def.iu_version; assignment at sparc_cpu_realizefn(). This means behavior will be kept exactly the same (except for the memory corruption bug fix). It would be nice to explicitly validate iu_version against target_ulong limits, but that would be a new feature (since the first version of this code, iu-version was parsed as 64-bit value value). It can be done later, once we have an appropriate API to define limits for integer properties. Fixes: de05005bf785 ("sparc: convert cpu features to qdev properties") Signed-off-by: Eduardo Habkost Acked-by: Mark Cave-Ayland --- Cc: Mark Cave-Ayland Cc: Artyom Tarasenko Cc: qemu-devel@nongnu.org --- target/sparc/cpu.h | 2 +- target/sparc/cpu.c | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h index b9369398f2..8ed0f4fef3 100644 --- a/target/sparc/cpu.h +++ b/target/sparc/cpu.h @@ -252,7 +252,7 @@ typedef struct trap_state { struct sparc_def_t { const char *name; - target_ulong iu_version; + uint64_t iu_version; uint32_t fpu_version; uint32_t mmu_version; uint32_t mmu_bm; diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index ec59a13eb8..5a9397f19a 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -576,7 +576,7 @@ void sparc_cpu_list(void) unsigned int i; for (i = 0; i < ARRAY_SIZE(sparc_defs); i++) { - qemu_printf("Sparc %16s IU " TARGET_FMT_lx + qemu_printf("Sparc %16s IU %" PRIx64 " FPU %08x MMU %08x NWINS %d ", sparc_defs[i].name, sparc_defs[i].iu_version, @@ -838,8 +838,7 @@ static Property sparc_cpu_properties[] = { DEFINE_PROP_BIT("hypv", SPARCCPU, env.def.features, 11, false), DEFINE_PROP_BIT("cmt", SPARCCPU, env.def.features, 12, false), DEFINE_PROP_BIT("gl", SPARCCPU, env.def.features, 13, false), - DEFINE_PROP_UNSIGNED("iu-version", SPARCCPU, env.def.iu_version, 0, - prop_info_uint64, target_ulong), + DEFINE_PROP_UINT64("iu-version", SPARCCPU, env.def.iu_version, 0), DEFINE_PROP_UINT32("fpu-version", SPARCCPU, env.def.fpu_version, 0), DEFINE_PROP_UINT32("mmu-version", SPARCCPU, env.def.mmu_version, 0), DEFINE_PROP("nwindows", SPARCCPU, env.def.nwindows, From patchwork Wed Nov 4 17:25:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 318591 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4C8FC388F9 for ; Wed, 4 Nov 2020 17:28:35 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 360A120759 for ; Wed, 4 Nov 2020 17:28:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PE+8dTVc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 360A120759 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:58752 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaMaI-0005v0-7C for qemu-devel@archiver.kernel.org; Wed, 04 Nov 2020 12:28:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60818) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaMXE-0000z5-Vr for qemu-devel@nongnu.org; Wed, 04 Nov 2020 12:25:24 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:45215) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaMXB-0008Ba-UW for qemu-devel@nongnu.org; Wed, 04 Nov 2020 12:25:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604510720; 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=bD8WHQ5vkPZgFU67Ydv6CRTwa7bMPjoclBtYbd6jK3c=; b=PE+8dTVc7ryyWQIzjWLiFTiAwjyeR1fzbRgipif/WPj69ofteLzRUfmVs2D2DIKNXv4T7m GKLf2dBssIBWpy9jMIC0x4iQJ0fMLGd8c0UrnAxQTu5/IFUPk8h5Up1PHR4ttu91CNDPCy 4VY7pqpz9rymvFErD3luDMHk5npfBFA= 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-528-eRHrlGKkOvqVzrcUNlO-EA-1; Wed, 04 Nov 2020 12:25:18 -0500 X-MC-Unique: eRHrlGKkOvqVzrcUNlO-EA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8BBC11028D51 for ; Wed, 4 Nov 2020 17:25:17 +0000 (UTC) Received: from localhost (ovpn-114-68.rdu2.redhat.com [10.10.114.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4E20660BFA; Wed, 4 Nov 2020 17:25:17 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Subject: [PATCH 2/7] qom: Save size of struct field in Property struct Date: Wed, 4 Nov 2020 12:25:07 -0500 Message-Id: <20201104172512.2381656-3-ehabkost@redhat.com> In-Reply-To: <20201104172512.2381656-1-ehabkost@redhat.com> References: <20201104172512.2381656-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 22:09:52 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=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: Igor Mammedov , "Daniel P. Berrange" , Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This will let the code that reads/writes the field ensure it will never go out of bounds. Signed-off-by: Eduardo Habkost --- Cc: Paolo Bonzini Cc: "Daniel P. Berrangé" Cc: Eduardo Habkost Cc: qemu-devel@nongnu.org --- include/qom/field-property.h | 3 +++ include/qom/property-types.h | 1 + qom/property-types.c | 1 + 3 files changed, 5 insertions(+) diff --git a/include/qom/field-property.h b/include/qom/field-property.h index bc866e1c93..e64a2b3c07 100644 --- a/include/qom/field-property.h +++ b/include/qom/field-property.h @@ -27,7 +27,10 @@ struct Property { */ const char *qdev_prop_name; const PropertyInfo *info; + /** @offset: offset of field in object instance struct */ ptrdiff_t offset; + /** @size: size of field in object instance struct */ + size_t size; uint8_t bitnr; /** * @set_default: true if the default value should be set from @defval, diff --git a/include/qom/property-types.h b/include/qom/property-types.h index 3a36e1fec5..17bf007234 100644 --- a/include/qom/property-types.h +++ b/include/qom/property-types.h @@ -28,6 +28,7 @@ extern const PropertyInfo prop_info_link; .info = &(_prop), \ .offset = offsetof(_state, _field) \ + type_check(_type, typeof_field(_state, _field)), \ + .size = sizeof(typeof_field(_state, _field)), \ __VA_ARGS__ \ } diff --git a/qom/property-types.c b/qom/property-types.c index f566c05ec2..856b5ae76d 100644 --- a/qom/property-types.c +++ b/qom/property-types.c @@ -485,6 +485,7 @@ static void set_prop_arraylen(Object *obj, Visitor *v, const char *name, * being inside the device struct. */ arrayprop->offset = eltptr - (void *)obj; + arrayprop->size = prop->arrayfieldsize; assert(object_field_prop_ptr(obj, arrayprop) == eltptr); object_property_add_field(obj, propname, arrayprop, op->allow_set); } From patchwork Wed Nov 4 17:25:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 318590 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9B09C388F9 for ; Wed, 4 Nov 2020 17:31:12 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0A3EA20759 for ; Wed, 4 Nov 2020 17:31:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="c9eQA0WU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0A3EA20759 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:38486 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaMcp-0000rC-22 for qemu-devel@archiver.kernel.org; Wed, 04 Nov 2020 12:31:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60906) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaMXT-0001Lr-89 for qemu-devel@nongnu.org; Wed, 04 Nov 2020 12:25:39 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:51392) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaMXP-0008IM-AL for qemu-devel@nongnu.org; Wed, 04 Nov 2020 12:25:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604510734; 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=qH+Ft2xr8oMmaql/QpsL3d2WQdY3tolquMseQzbcMBo=; b=c9eQA0WUBtaaXtdvvJN58eXmSuQ3NeT9FuVCO46TS4lypO8l5QlhSDrGtZd8mNyIBZPrHx 2epbtlf9Hg8m1WEvQgA0CuTqScfB7ORyhRHUrRMq2OQj8QyNQtCoYcs1/43JODFVdYAb4S oy/TL/zlT/1Kgc++g5/bRD9MnscN7N0= 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-206-BliftGsjOkqSm4-6LQDSYg-1; Wed, 04 Nov 2020 12:25:31 -0500 X-MC-Unique: BliftGsjOkqSm4-6LQDSYg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 488668049CB; Wed, 4 Nov 2020 17:25:29 +0000 (UTC) Received: from localhost (ovpn-114-68.rdu2.redhat.com [10.10.114.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4A6315C5DE; Wed, 4 Nov 2020 17:25:21 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Subject: [PATCH 4/7] qom: Replace void* parameter with Property* on field getters/setters Date: Wed, 4 Nov 2020 12:25:09 -0500 Message-Id: <20201104172512.2381656-5-ehabkost@redhat.com> In-Reply-To: <20201104172512.2381656-1-ehabkost@redhat.com> References: <20201104172512.2381656-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 22:09:52 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=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: Matthew Rosato , Paul Durrant , Mark Cave-Ayland , Stefano Stabellini , qemu-block@nongnu.org, Stefan Berger , David Hildenbrand , Halil Pasic , Christian Borntraeger , Anthony Perard , xen-devel@lists.xenproject.org, Artyom Tarasenko , Thomas Huth , qemu-s390x@nongnu.org, Igor Mammedov , Richard Henderson , Kevin Wolf , "Daniel P. Berrange" , Cornelia Huck , Alex Williamson , Max Reitz , Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" All field property getters and setters must interpret the fourth argument as Property*. Change the function signature of field property getters and setters to indicate that. Signed-off-by: Eduardo Habkost Acked-by: Cornelia Huck --- Cc: Stefan Berger Cc: Stefano Stabellini Cc: Anthony Perard Cc: Paul Durrant Cc: Kevin Wolf Cc: Max Reitz Cc: Paolo Bonzini Cc: "Daniel P. Berrangé" Cc: Eduardo Habkost Cc: Richard Henderson Cc: David Hildenbrand Cc: Cornelia Huck Cc: Thomas Huth Cc: Halil Pasic Cc: Christian Borntraeger Cc: Matthew Rosato Cc: Alex Williamson Cc: Mark Cave-Ayland Cc: Artyom Tarasenko Cc: qemu-devel@nongnu.org Cc: xen-devel@lists.xenproject.org Cc: qemu-block@nongnu.org Cc: qemu-s390x@nongnu.org --- include/qom/field-property-internal.h | 8 +- include/qom/field-property.h | 26 ++++--- backends/tpm/tpm_util.c | 11 ++- hw/block/xen-block.c | 6 +- hw/core/qdev-properties-system.c | 86 +++++++++------------- hw/s390x/css.c | 6 +- hw/s390x/s390-pci-bus.c | 6 +- hw/vfio/pci-quirks.c | 10 +-- qom/property-types.c | 102 +++++++++----------------- target/sparc/cpu.c | 4 +- 10 files changed, 105 insertions(+), 160 deletions(-) diff --git a/include/qom/field-property-internal.h b/include/qom/field-property-internal.h index 7aa27ce836..bc7d25033d 100644 --- a/include/qom/field-property-internal.h +++ b/include/qom/field-property-internal.h @@ -9,9 +9,9 @@ #define QOM_STATIC_PROPERTY_INTERNAL_H void field_prop_get_enum(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp); + Property *prop, Error **errp); void field_prop_set_enum(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp); + Property *prop, Error **errp); void field_prop_set_default_value_enum(ObjectProperty *op, const Property *prop); @@ -21,9 +21,9 @@ void field_prop_set_default_value_uint(ObjectProperty *op, const Property *prop); void field_prop_get_int32(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp); + Property *prop, Error **errp); void field_prop_get_size32(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp); + Property *prop, Error **errp); /** * object_property_add_field: Add a field property to an object instance diff --git a/include/qom/field-property.h b/include/qom/field-property.h index e64a2b3c07..438bb25896 100644 --- a/include/qom/field-property.h +++ b/include/qom/field-property.h @@ -54,6 +54,18 @@ struct Property { const char *link_type; }; +/** + * typedef FieldAccessor: a field property getter or setter function + * @obj: the object instance + * @v: the visitor that contains the property data + * @name: the name of the property + * @prop: Field property definition + * @errp: pointer to error information + */ +typedef void FieldAccessor(Object *obj, Visitor *v, + const char *name, Property *prop, + Error **errp); + /** * struct PropertyInfo: information on a specific QOM property type */ @@ -71,16 +83,10 @@ struct PropertyInfo { /** @create: Optional callback for creation of property */ ObjectProperty *(*create)(ObjectClass *oc, const char *name, Property *prop); - /** - * @get: Property getter. The opaque parameter will point to - * the &Property struct for the property. - */ - ObjectPropertyAccessor *get; - /** - * @set: Property setter. The opaque parameter will point to - * the &Property struct for the property. - */ - ObjectPropertyAccessor *set; + /** @get: Property getter */ + FieldAccessor *get; + /** @set: Property setter */ + FieldAccessor *set; /** * @release: Optional release function, called when the object * is destroyed diff --git a/backends/tpm/tpm_util.c b/backends/tpm/tpm_util.c index bb1ab34a75..e8837938e5 100644 --- a/backends/tpm/tpm_util.c +++ b/backends/tpm/tpm_util.c @@ -32,10 +32,10 @@ /* tpm backend property */ -static void get_tpm(Object *obj, Visitor *v, const char *name, void *opaque, - Error **errp) +static void get_tpm(Object *obj, Visitor *v, const char *name, + Property *prop, Error **errp) { - TPMBackend **be = object_field_prop_ptr(obj, opaque); + TPMBackend **be = object_field_prop_ptr(obj, prop); char *p; p = g_strdup(*be ? (*be)->id : ""); @@ -43,10 +43,9 @@ static void get_tpm(Object *obj, Visitor *v, const char *name, void *opaque, g_free(p); } -static void set_tpm(Object *obj, Visitor *v, const char *name, void *opaque, - Error **errp) +static void set_tpm(Object *obj, Visitor *v, const char *name, + Property *prop, Error **errp) { - Property *prop = opaque; TPMBackend *s, **be = object_field_prop_ptr(obj, prop); char *str; diff --git a/hw/block/xen-block.c b/hw/block/xen-block.c index 718d886e5c..c1ee634639 100644 --- a/hw/block/xen-block.c +++ b/hw/block/xen-block.c @@ -333,9 +333,8 @@ static char *disk_to_vbd_name(unsigned int disk) } static void xen_block_get_vdev(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) + Property *prop, Error **errp) { - Property *prop = opaque; XenBlockVdev *vdev = object_field_prop_ptr(obj, prop); char *str; @@ -393,9 +392,8 @@ static int vbd_name_to_disk(const char *name, const char **endp, } static void xen_block_set_vdev(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) + Property *prop, Error **errp) { - Property *prop = opaque; XenBlockVdev *vdev = object_field_prop_ptr(obj, prop); char *str, *p; const char *end; diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c index 8da68f076c..4c649cb4b2 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -58,10 +58,9 @@ static bool check_prop_still_unset(Object *obj, const char *name, /* --- drive --- */ -static void get_drive(Object *obj, Visitor *v, const char *name, void *opaque, - Error **errp) +static void get_drive(Object *obj, Visitor *v, const char *name, + Property *prop, Error **errp) { - Property *prop = opaque; void **ptr = object_field_prop_ptr(obj, prop); const char *value; char *p; @@ -165,16 +164,16 @@ fail: g_free(str); } -static void set_drive(Object *obj, Visitor *v, const char *name, void *opaque, +static void set_drive(Object *obj, Visitor *v, const char *name, Property *prop, Error **errp) { - set_drive_helper(obj, v, name, opaque, false, errp); + set_drive_helper(obj, v, name, prop, false, errp); } static void set_drive_iothread(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) + Property *prop, Error **errp) { - set_drive_helper(obj, v, name, opaque, true, errp); + set_drive_helper(obj, v, name, prop, true, errp); } static void release_drive(Object *obj, const char *name, void *opaque) @@ -211,10 +210,10 @@ const PropertyInfo qdev_prop_drive_iothread = { /* --- character device --- */ -static void get_chr(Object *obj, Visitor *v, const char *name, void *opaque, - Error **errp) +static void get_chr(Object *obj, Visitor *v, const char *name, + Property *prop, Error **errp) { - CharBackend *be = object_field_prop_ptr(obj, opaque); + CharBackend *be = object_field_prop_ptr(obj, prop); char *p; p = g_strdup(be->chr && be->chr->label ? be->chr->label : ""); @@ -222,10 +221,9 @@ static void get_chr(Object *obj, Visitor *v, const char *name, void *opaque, g_free(p); } -static void set_chr(Object *obj, Visitor *v, const char *name, void *opaque, - Error **errp) +static void set_chr(Object *obj, Visitor *v, const char *name, + Property *prop, Error **errp) { - Property *prop = opaque; CharBackend *be = object_field_prop_ptr(obj, prop); Chardev *s; char *str; @@ -282,10 +280,9 @@ const PropertyInfo qdev_prop_chr = { * 01:02:03:04:05:06 * 01-02-03-04-05-06 */ -static void get_mac(Object *obj, Visitor *v, const char *name, void *opaque, - Error **errp) +static void get_mac(Object *obj, Visitor *v, const char *name, + Property *prop, Error **errp) { - Property *prop = opaque; MACAddr *mac = object_field_prop_ptr(obj, prop); char buffer[2 * 6 + 5 + 1]; char *p = buffer; @@ -297,10 +294,9 @@ static void get_mac(Object *obj, Visitor *v, const char *name, void *opaque, visit_type_str(v, name, &p, errp); } -static void set_mac(Object *obj, Visitor *v, const char *name, void *opaque, - Error **errp) +static void set_mac(Object *obj, Visitor *v, const char *name, + Property *prop, Error **errp) { - Property *prop = opaque; MACAddr *mac = object_field_prop_ptr(obj, prop); int i, pos; char *str; @@ -360,9 +356,8 @@ void qdev_prop_set_macaddr(DeviceState *dev, const char *name, /* --- netdev device --- */ static void get_netdev(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) + Property *prop, Error **errp) { - Property *prop = opaque; NICPeers *peers_ptr = object_field_prop_ptr(obj, prop); char *p = g_strdup(peers_ptr->ncs[0] ? peers_ptr->ncs[0]->name : ""); @@ -371,9 +366,8 @@ static void get_netdev(Object *obj, Visitor *v, const char *name, } static void set_netdev(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) + Property *prop, Error **errp) { - Property *prop = opaque; NICPeers *peers_ptr = object_field_prop_ptr(obj, prop); NetClientState **ncs = peers_ptr->ncs; NetClientState *peers[MAX_QUEUE_NUM]; @@ -433,9 +427,8 @@ const PropertyInfo qdev_prop_netdev = { /* --- audiodev --- */ static void get_audiodev(Object *obj, Visitor *v, const char* name, - void *opaque, Error **errp) + Property *prop, Error **errp) { - Property *prop = opaque; QEMUSoundCard *card = object_field_prop_ptr(obj, prop); char *p = g_strdup(audio_get_id(card)); @@ -444,9 +437,8 @@ static void get_audiodev(Object *obj, Visitor *v, const char* name, } static void set_audiodev(Object *obj, Visitor *v, const char* name, - void *opaque, Error **errp) + Property *prop, Error **errp) { - Property *prop = opaque; QEMUSoundCard *card = object_field_prop_ptr(obj, prop); AudioState *state; int err = 0; @@ -545,10 +537,9 @@ const PropertyInfo qdev_prop_losttickpolicy = { /* --- blocksize --- */ static void set_blocksize(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) + Property *prop, Error **errp) { DeviceState *dev = DEVICE(obj); - Property *prop = opaque; uint32_t *ptr = object_field_prop_ptr(obj, prop); uint64_t value; Error *local_err = NULL; @@ -634,9 +625,8 @@ const PropertyInfo qdev_prop_multifd_compression = { * and type is a non-negative decimal integer */ static void get_reserved_region(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) + Property *prop, Error **errp) { - Property *prop = opaque; ReservedRegion *rr = object_field_prop_ptr(obj, prop); char buffer[64]; char *p = buffer; @@ -650,9 +640,8 @@ static void get_reserved_region(Object *obj, Visitor *v, const char *name, } static void set_reserved_region(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) + Property *prop, Error **errp) { - Property *prop = opaque; ReservedRegion *rr = object_field_prop_ptr(obj, prop); Error *local_err = NULL; const char *endptr; @@ -712,9 +701,8 @@ const PropertyInfo qdev_prop_reserved_region = { * bus-local address, i.e. "$slot" or "$slot.$fn" */ static void set_pci_devfn(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) + Property *prop, Error **errp) { - Property *prop = opaque; int32_t value, *ptr = object_field_prop_ptr(obj, prop); unsigned int slot, fn, n; char *str; @@ -774,9 +762,8 @@ const PropertyInfo qdev_prop_pci_devfn = { /* --- pci host address --- */ static void get_pci_host_devaddr(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) + Property *prop, Error **errp) { - Property *prop = opaque; PCIHostDeviceAddress *addr = object_field_prop_ptr(obj, prop); char buffer[] = "ffff:ff:ff.f"; char *p = buffer; @@ -800,9 +787,8 @@ static void get_pci_host_devaddr(Object *obj, Visitor *v, const char *name, * if is not supplied, it's assumed to be 0. */ static void set_pci_host_devaddr(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) + Property *prop, Error **errp) { - Property *prop = opaque; PCIHostDeviceAddress *addr = object_field_prop_ptr(obj, prop); char *str, *p; const char *e; @@ -889,9 +875,8 @@ const PropertyInfo qdev_prop_off_auto_pcibar = { /* --- PCIELinkSpeed 2_5/5/8/16 -- */ static void get_prop_pcielinkspeed(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) + Property *prop, Error **errp) { - Property *prop = opaque; PCIExpLinkSpeed *p = object_field_prop_ptr(obj, prop); int speed; @@ -917,9 +902,8 @@ static void get_prop_pcielinkspeed(Object *obj, Visitor *v, const char *name, } static void set_prop_pcielinkspeed(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) + Property *prop, Error **errp) { - Property *prop = opaque; PCIExpLinkSpeed *p = object_field_prop_ptr(obj, prop); int speed; @@ -959,9 +943,8 @@ const PropertyInfo qdev_prop_pcie_link_speed = { /* --- PCIELinkWidth 1/2/4/8/12/16/32 -- */ static void get_prop_pcielinkwidth(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) + Property *prop, Error **errp) { - Property *prop = opaque; PCIExpLinkWidth *p = object_field_prop_ptr(obj, prop); int width; @@ -996,9 +979,8 @@ static void get_prop_pcielinkwidth(Object *obj, Visitor *v, const char *name, } static void set_prop_pcielinkwidth(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) + Property *prop, Error **errp) { - Property *prop = opaque; PCIExpLinkWidth *p = object_field_prop_ptr(obj, prop); int width; @@ -1046,10 +1028,9 @@ const PropertyInfo qdev_prop_pcie_link_width = { /* --- UUID --- */ -static void get_uuid(Object *obj, Visitor *v, const char *name, void *opaque, - Error **errp) +static void get_uuid(Object *obj, Visitor *v, const char *name, + Property *prop, Error **errp) { - Property *prop = opaque; QemuUUID *uuid = object_field_prop_ptr(obj, prop); char buffer[UUID_FMT_LEN + 1]; char *p = buffer; @@ -1061,10 +1042,9 @@ static void get_uuid(Object *obj, Visitor *v, const char *name, void *opaque, #define UUID_VALUE_AUTO "auto" -static void set_uuid(Object *obj, Visitor *v, const char *name, void *opaque, - Error **errp) +static void set_uuid(Object *obj, Visitor *v, const char *name, + Property *prop, Error **errp) { - Property *prop = opaque; QemuUUID *uuid = object_field_prop_ptr(obj, prop); char *str; diff --git a/hw/s390x/css.c b/hw/s390x/css.c index fe47751df4..1400d80689 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -2341,9 +2341,8 @@ void css_reset(void) } static void get_css_devid(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) + Property *prop, Error **errp) { - Property *prop = opaque; CssDevId *dev_id = object_field_prop_ptr(obj, prop); char buffer[] = "xx.x.xxxx"; char *p = buffer; @@ -2370,9 +2369,8 @@ static void get_css_devid(Object *obj, Visitor *v, const char *name, * parse .. and assert valid range for cssid/ssid */ static void set_css_devid(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) + Property *prop, Error **errp) { - Property *prop = opaque; CssDevId *dev_id = object_field_prop_ptr(obj, prop); char *str; int num, n1, n2; diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index 99b18d56ba..a29bba17b4 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -1320,19 +1320,17 @@ static void s390_pci_device_reset(DeviceState *dev) } static void s390_pci_get_fid(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) + Property *prop, Error **errp) { - Property *prop = opaque; uint32_t *ptr = object_field_prop_ptr(obj, prop); visit_type_uint32(v, name, ptr, errp); } static void s390_pci_set_fid(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) + Property *prop, Error **errp) { S390PCIBusDevice *zpci = S390_PCI_DEVICE(obj); - Property *prop = opaque; uint32_t *ptr = object_field_prop_ptr(obj, prop); if (!visit_type_uint32(v, name, ptr, errp)) { diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c index fc8d63c850..34f5f5dce2 100644 --- a/hw/vfio/pci-quirks.c +++ b/hw/vfio/pci-quirks.c @@ -1485,20 +1485,18 @@ void vfio_setup_resetfn_quirk(VFIOPCIDevice *vdev) * https://lists.gnu.org/archive/html/qemu-devel/2017-08/pdfUda5iEpgOS.pdf */ static void get_nv_gpudirect_clique_id(Object *obj, Visitor *v, - const char *name, void *opaque, - Error **errp) + const char *name, + Property *prop, Error **errp) { - Property *prop = opaque; uint8_t *ptr = object_field_prop_ptr(obj, prop); visit_type_uint8(v, name, ptr, errp); } static void set_nv_gpudirect_clique_id(Object *obj, Visitor *v, - const char *name, void *opaque, - Error **errp) + const char *name, + Property *prop, Error **errp) { - Property *prop = opaque; uint8_t value, *ptr = object_field_prop_ptr(obj, prop); if (!visit_type_uint8(v, name, &value, errp)) { diff --git a/qom/property-types.c b/qom/property-types.c index 856b5ae76d..82a5932f4a 100644 --- a/qom/property-types.c +++ b/qom/property-types.c @@ -8,18 +8,16 @@ #include "qemu/uuid.h" void field_prop_get_enum(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) + Property *prop, Error **errp) { - Property *prop = opaque; int *ptr = object_field_prop_ptr(obj, prop); visit_type_enum(v, name, ptr, prop->info->enum_table, errp); } void field_prop_set_enum(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) + Property *prop, Error **errp) { - Property *prop = opaque; int *ptr = object_field_prop_ptr(obj, prop); visit_type_enum(v, name, ptr, prop->info->enum_table, errp); @@ -59,9 +57,8 @@ static void bit_prop_set(Object *obj, Property *props, bool val) } static void prop_get_bit(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) + Property *prop, Error **errp) { - Property *prop = opaque; uint32_t *p = object_field_prop_ptr(obj, prop); bool value = (*p & qdev_get_prop_mask(prop)) != 0; @@ -69,9 +66,8 @@ static void prop_get_bit(Object *obj, Visitor *v, const char *name, } static void prop_set_bit(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) + Property *prop, Error **errp) { - Property *prop = opaque; bool value; if (!visit_type_bool(v, name, &value, errp)) { @@ -113,9 +109,8 @@ static void bit64_prop_set(Object *obj, Property *props, bool val) } static void prop_get_bit64(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) + Property *prop, Error **errp) { - Property *prop = opaque; uint64_t *p = object_field_prop_ptr(obj, prop); bool value = (*p & qdev_get_prop_mask64(prop)) != 0; @@ -123,9 +118,8 @@ static void prop_get_bit64(Object *obj, Visitor *v, const char *name, } static void prop_set_bit64(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) + Property *prop, Error **errp) { - Property *prop = opaque; bool value; if (!visit_type_bool(v, name, &value, errp)) { @@ -144,19 +138,17 @@ const PropertyInfo prop_info_bit64 = { /* --- bool --- */ -static void get_bool(Object *obj, Visitor *v, const char *name, void *opaque, - Error **errp) +static void get_bool(Object *obj, Visitor *v, const char *name, + Property *prop, Error **errp) { - Property *prop = opaque; bool *ptr = object_field_prop_ptr(obj, prop); visit_type_bool(v, name, ptr, errp); } -static void set_bool(Object *obj, Visitor *v, const char *name, void *opaque, - Error **errp) +static void set_bool(Object *obj, Visitor *v, const char *name, + Property *prop, Error **errp) { - Property *prop = opaque; bool *ptr = object_field_prop_ptr(obj, prop); visit_type_bool(v, name, ptr, errp); @@ -171,19 +163,17 @@ const PropertyInfo prop_info_bool = { /* --- 8bit integer --- */ -static void get_uint8(Object *obj, Visitor *v, const char *name, void *opaque, - Error **errp) +static void get_uint8(Object *obj, Visitor *v, const char *name, + Property *prop, Error **errp) { - Property *prop = opaque; uint8_t *ptr = object_field_prop_ptr(obj, prop); visit_type_uint8(v, name, ptr, errp); } -static void set_uint8(Object *obj, Visitor *v, const char *name, void *opaque, - Error **errp) +static void set_uint8(Object *obj, Visitor *v, const char *name, + Property *prop, Error **errp) { - Property *prop = opaque; uint8_t *ptr = object_field_prop_ptr(obj, prop); visit_type_uint8(v, name, ptr, errp); @@ -211,18 +201,16 @@ const PropertyInfo prop_info_uint8 = { /* --- 16bit integer --- */ static void get_uint16(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) + Property *prop, Error **errp) { - Property *prop = opaque; uint16_t *ptr = object_field_prop_ptr(obj, prop); visit_type_uint16(v, name, ptr, errp); } static void set_uint16(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) + Property *prop, Error **errp) { - Property *prop = opaque; uint16_t *ptr = object_field_prop_ptr(obj, prop); visit_type_uint16(v, name, ptr, errp); @@ -238,36 +226,32 @@ const PropertyInfo prop_info_uint16 = { /* --- 32bit integer --- */ static void get_uint32(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) + Property *prop, Error **errp) { - Property *prop = opaque; uint32_t *ptr = object_field_prop_ptr(obj, prop); visit_type_uint32(v, name, ptr, errp); } static void set_uint32(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) + Property *prop, Error **errp) { - Property *prop = opaque; uint32_t *ptr = object_field_prop_ptr(obj, prop); visit_type_uint32(v, name, ptr, errp); } void field_prop_get_int32(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) + Property *prop, Error **errp) { - Property *prop = opaque; int32_t *ptr = object_field_prop_ptr(obj, prop); visit_type_int32(v, name, ptr, errp); } -static void set_int32(Object *obj, Visitor *v, const char *name, void *opaque, - Error **errp) +static void set_int32(Object *obj, Visitor *v, const char *name, + Property *prop, Error **errp) { - Property *prop = opaque; int32_t *ptr = object_field_prop_ptr(obj, prop); visit_type_int32(v, name, ptr, errp); @@ -290,36 +274,32 @@ const PropertyInfo prop_info_int32 = { /* --- 64bit integer --- */ static void get_uint64(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) + Property *prop, Error **errp) { - Property *prop = opaque; uint64_t *ptr = object_field_prop_ptr(obj, prop); visit_type_uint64(v, name, ptr, errp); } static void set_uint64(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) + Property *prop, Error **errp) { - Property *prop = opaque; uint64_t *ptr = object_field_prop_ptr(obj, prop); visit_type_uint64(v, name, ptr, errp); } static void get_int64(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) + Property *prop, Error **errp) { - Property *prop = opaque; int64_t *ptr = object_field_prop_ptr(obj, prop); visit_type_int64(v, name, ptr, errp); } static void set_int64(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) + Property *prop, Error **errp) { - Property *prop = opaque; int64_t *ptr = object_field_prop_ptr(obj, prop); visit_type_int64(v, name, ptr, errp); @@ -348,9 +328,8 @@ static void release_string(Object *obj, const char *name, void *opaque) } static void get_string(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) + Property *prop, Error **errp) { - Property *prop = opaque; char **ptr = object_field_prop_ptr(obj, prop); if (!*ptr) { @@ -362,9 +341,8 @@ static void get_string(Object *obj, Visitor *v, const char *name, } static void set_string(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) + Property *prop, Error **errp) { - Property *prop = opaque; char **ptr = object_field_prop_ptr(obj, prop); char *str; @@ -396,19 +374,17 @@ const PropertyInfo prop_info_on_off_auto = { /* --- 32bit unsigned int 'size' type --- */ void field_prop_get_size32(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) + Property *prop, Error **errp) { - Property *prop = opaque; uint32_t *ptr = object_field_prop_ptr(obj, prop); uint64_t value = *ptr; visit_type_size(v, name, &value, errp); } -static void set_size32(Object *obj, Visitor *v, const char *name, void *opaque, - Error **errp) +static void set_size32(Object *obj, Visitor *v, const char *name, + Property *prop, Error **errp) { - Property *prop = opaque; uint32_t *ptr = object_field_prop_ptr(obj, prop); uint64_t value; @@ -437,14 +413,8 @@ const PropertyInfo prop_info_size32 = { /* --- support for array properties --- */ static void set_prop_arraylen(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) + Property *prop, Error **errp) { - /* Setter for the property which defines the length of a - * variable-sized property array. As well as actually setting the - * array-length field in the device struct, we have to create the - * array itself and dynamically add the corresponding properties. - */ - Property *prop = opaque; ObjectProperty *op = object_property_find_err(obj, name, &error_abort); uint32_t *alenptr = object_field_prop_ptr(obj, prop); void **arrayptr = (void *)obj + prop->arrayoffset; @@ -500,19 +470,17 @@ const PropertyInfo prop_info_arraylen = { /* --- 64bit unsigned int 'size' type --- */ -static void get_size(Object *obj, Visitor *v, const char *name, void *opaque, - Error **errp) +static void get_size(Object *obj, Visitor *v, const char *name, + Property *prop, Error **errp) { - Property *prop = opaque; uint64_t *ptr = object_field_prop_ptr(obj, prop); visit_type_size(v, name, ptr, errp); } -static void set_size(Object *obj, Visitor *v, const char *name, void *opaque, - Error **errp) +static void set_size(Object *obj, Visitor *v, const char *name, + Property *prop, Error **errp) { - Property *prop = opaque; uint64_t *ptr = object_field_prop_ptr(obj, prop); visit_type_size(v, name, ptr, errp); diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index 5a9397f19a..3acc99c29c 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -787,7 +787,7 @@ static void sparc_cpu_initfn(Object *obj) } static void sparc_get_nwindows(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) + Property *prop, Error **errp) { SPARCCPU *cpu = SPARC_CPU(obj); int64_t value = cpu->env.def.nwindows; @@ -796,7 +796,7 @@ static void sparc_get_nwindows(Object *obj, Visitor *v, const char *name, } static void sparc_set_nwindows(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) + Property *prop, Error **errp) { const int64_t min = MIN_NWINDOWS; const int64_t max = MAX_NWINDOWS; From patchwork Wed Nov 4 17:25:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 318592 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 978A9C2D0A3 for ; Wed, 4 Nov 2020 17:27:14 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0D71120759 for ; Wed, 4 Nov 2020 17:27:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="W3/bvtJt" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0D71120759 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:52464 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaMYz-0003Lv-08 for qemu-devel@archiver.kernel.org; Wed, 04 Nov 2020 12:27:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60964) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaMXe-0001XU-FN for qemu-devel@nongnu.org; Wed, 04 Nov 2020 12:25:50 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:59259) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaMXc-0008Km-Od for qemu-devel@nongnu.org; Wed, 04 Nov 2020 12:25:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604510748; 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=kwACAshq5NS9uT54H9fF11qSNq1GFrFnRwSqIb1jpDQ=; b=W3/bvtJtb/WNWBN+WopsT6FfJJgpjFOHpsM58J/GqnOuQ3hSfMwY+Y+kCv5nM+UgbNkIBo 8Gos7E/61y9Be9UIx0EguHNseSTbWIpf624ljqU8XtfgdfUjkCaP2NWtXxrvwZfBvm2+0/ dutgqZKRfUmqqGHCZ/yHf7SWJYkuTqo= 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-425-FPCIqXdGNmuW79xPauGz0Q-1; Wed, 04 Nov 2020 12:25:46 -0500 X-MC-Unique: FPCIqXdGNmuW79xPauGz0Q-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4144911BD343; Wed, 4 Nov 2020 17:25:45 +0000 (UTC) Received: from localhost (ovpn-114-68.rdu2.redhat.com [10.10.114.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id D0B8E5DA33; Wed, 4 Nov 2020 17:25:44 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Subject: [PATCH 7/7] sparc: Use FIELD_PTR at nwindows getter/setter Date: Wed, 4 Nov 2020 12:25:12 -0500 Message-Id: <20201104172512.2381656-8-ehabkost@redhat.com> In-Reply-To: <20201104172512.2381656-1-ehabkost@redhat.com> References: <20201104172512.2381656-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] 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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: Igor Mammedov , Mark Cave-Ayland , "Daniel P. Berrange" , Artyom Tarasenko , Paolo Bonzini Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This makes the nwindows getter and setter more consistent with the other field getters and setters (which work with any struct field). Signed-off-by: Eduardo Habkost Acked-by: Mark Cave-Ayland --- Cc: Mark Cave-Ayland Cc: Artyom Tarasenko Cc: qemu-devel@nongnu.org --- target/sparc/cpu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index 3acc99c29c..8bf02a4fe0 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -789,8 +789,8 @@ static void sparc_cpu_initfn(Object *obj) static void sparc_get_nwindows(Object *obj, Visitor *v, const char *name, Property *prop, Error **errp) { - SPARCCPU *cpu = SPARC_CPU(obj); - int64_t value = cpu->env.def.nwindows; + uint32_t *ptr = FIELD_PTR(obj, prop, uint32_t); + int64_t value = *ptr; visit_type_int(v, name, &value, errp); } @@ -798,9 +798,9 @@ static void sparc_get_nwindows(Object *obj, Visitor *v, const char *name, static void sparc_set_nwindows(Object *obj, Visitor *v, const char *name, Property *prop, Error **errp) { + uint32_t *ptr = FIELD_PTR(obj, prop, uint32_t); const int64_t min = MIN_NWINDOWS; const int64_t max = MAX_NWINDOWS; - SPARCCPU *cpu = SPARC_CPU(obj); int64_t value; if (!visit_type_int(v, name, &value, errp)) { @@ -814,7 +814,7 @@ static void sparc_set_nwindows(Object *obj, Visitor *v, const char *name, value, min, max); return; } - cpu->env.def.nwindows = value; + *ptr = value; } static PropertyInfo qdev_prop_nwindows = {