From patchwork Tue Oct 3 17:30:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 1842780 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=ZtoABmUt; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4S0Pzf2nmpz1yng for ; Wed, 4 Oct 2023 04:33:02 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnjEw-0008Lh-Ax; Tue, 03 Oct 2023 13:31:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qnjEi-0008Fw-Rt for qemu-devel@nongnu.org; Tue, 03 Oct 2023 13:31:18 -0400 Received: from mail-oo1-xc2f.google.com ([2607:f8b0:4864:20::c2f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qnjEg-0007Ss-DU for qemu-devel@nongnu.org; Tue, 03 Oct 2023 13:31:08 -0400 Received: by mail-oo1-xc2f.google.com with SMTP id 006d021491bc7-57bb6a2481fso650103eaf.1 for ; Tue, 03 Oct 2023 10:31:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1696354265; x=1696959065; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=i3wrIxgr2m5oHMVkH4v8wSAkRBNGt7xc6AFyiVFHwxo=; b=ZtoABmUtIrXDFvVTVJsSXPZ8klkFsGAczdU7RZhe6k4uNKZH0vqbl0xuro4/inI+KL Mxm8zJiNuZwknkE0oah1jSnbq7bwi7CIOXKrYtSNvftEhyxmvrU9a91RfPW6wm0H9zTI h9Lg87TRUrw5pettygtkRk5VzOi3EfjSqKT6qnMciDaSpi/7SKHWRhVLS4l9Mrlub47h l9tPy80rBFlVdOOeDcwNULbqnD9EC5oqL3VlNEe4cknEMV82ZpThyEz7c/8/Gfny6+qH BG6qHtnEgo1YLEF2YK3F2yHR4+riy5YhKk3k7ATqydRxnOE8QE7Bw3X1Dv9CS/y4sG0/ W8yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696354265; x=1696959065; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=i3wrIxgr2m5oHMVkH4v8wSAkRBNGt7xc6AFyiVFHwxo=; b=kAZxKcV+42NlLOrzbEMQNx4t13PpWSrGf48czUI0KSNiCRZf4ibjwtnN26fLX06kk3 9OGAfycjitMUv+ViFH1SscGD/jXNXsqphdyvy+Qcjd93jBeezJ+BEkWoElGmOwZi5DDn 2b2qZSMFsM+V1cu71PvObXDYXLdtiIEyU2Y6IPpiK5gpAfLRgxu6UQ3wx7SmxwERAe1J vjWc/E2TmqOklh7IvvXYaaDbidyPo5iIdpI9oprQo6ZErn4UdvGjrkgKLBnl7F/wL2gR kOSF6BKrS3xou6E9JVb7mduyN/ozDt0r8ZfS/RD8jrb9sc0UGtTABanxjWhhbxinE4zb I7RA== X-Gm-Message-State: AOJu0Yw3YaHdxKDELQuBaHKVjFBVi7HJJAYscKK1OoZRbhW8UxcabAyO QN2Uy9wWcZM0JSeiDymSzDbTEV7m9fxk17TdzMc= X-Google-Smtp-Source: AGHT+IGSmQIacppaytt8AKctsYAV1IxSWjsvHjqVHzBtBgXUEZ2jNRgDnItZlP1BzbutaQxO6LeIgQ== X-Received: by 2002:a05:6358:720c:b0:141:162:b0d8 with SMTP id h12-20020a056358720c00b001410162b0d8mr59585rwa.30.1696354265314; Tue, 03 Oct 2023 10:31:05 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id n7-20020aa78a47000000b00692c5b1a731sm1620195pfa.186.2023.10.03.10.31.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 10:31:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 10/47] qom: Propagate alignment through type system Date: Tue, 3 Oct 2023 10:30:15 -0700 Message-Id: <20231003173052.1601813-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231003173052.1601813-1-richard.henderson@linaro.org> References: <20231003173052.1601813-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::c2f; envelope-from=richard.henderson@linaro.org; helo=mail-oo1-xc2f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Propagate alignment just like size. This is required in order to get the correct alignment on most cpu subclasses where the size and alignment is only specified for the base cpu type. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- qom/object.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/qom/object.c b/qom/object.c index e25f1e96db..8557fe8e4e 100644 --- a/qom/object.c +++ b/qom/object.c @@ -220,6 +220,19 @@ static size_t type_object_get_size(TypeImpl *ti) return 0; } +static size_t type_object_get_align(TypeImpl *ti) +{ + if (ti->instance_align) { + return ti->instance_align; + } + + if (type_has_parent(ti)) { + return type_object_get_align(type_get_parent(ti)); + } + + return 0; +} + size_t object_type_get_instance_size(const char *typename) { TypeImpl *type = type_get_by_name(typename); @@ -293,6 +306,7 @@ static void type_initialize(TypeImpl *ti) ti->class_size = type_class_get_size(ti); ti->instance_size = type_object_get_size(ti); + ti->instance_align = type_object_get_align(ti); /* Any type with zero instance_size is implicitly abstract. * This means interface types are all abstract. */