From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4EBE2459AD7 for ; Wed, 22 Jul 2026 23:14:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.197 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784762065; cv=none; b=tO3NF/A6gYUv2J2SkMvVWfM3mbbdJUgo6FESEeQdwRWmjz0vt+6+YbjDtYCsxeWc6V/k3M1jFk2jHaHu1wbm0jyZhAUpZStvgnyfqYVrEVnsQ7LdwQ7xW6uvPjkf3ZCde4Zr6XX2AJvjzGcepPXk49K/L67x+CmMTGXOpxEWYSQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784762065; c=relaxed/simple; bh=MN5wgOlznVkl+BjeEs809JtcBQkMpu0tStRwIcnoZBo=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=lF7virq1IntXHiUnPrK+GaUyQm4OHliFIf+7qziK2ahRNCSLdF47nI4eLmOh095/CS2fYNNvTQ81uAitRElKDX6eq1LQvAcCK62+PSqFv55G3zK0h8KFUlbE9p5tXlndVewCrCnAfBbjV214P7dHGaI2EP8/rFCwYVj5a0B2gkA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--wyihan.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=WjzhSAUw; arc=none smtp.client-ip=209.85.215.197 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--wyihan.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="WjzhSAUw" Received: by mail-pg1-f197.google.com with SMTP id 41be03b00d2f7-c89704da8c7so114804a12.0 for ; Wed, 22 Jul 2026 16:14:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1784762062; x=1785366862; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=HNI6BG2rRalx1BcQoBnUKDa+4TlUreIqsReX1yE6FOI=; b=WjzhSAUwj4CugvxBARKuulkAurDs2RyzMe+Z+FXWLD3KT3wFr9jfyg56AAEQVYEW91 dsBkDOUBIgw9wopVb2YgTHqi2i3SIt8VTYywy3VVjkTPqka02Or5f+HLEqaw7V7lS8d7 V6OXasDQZKySOqdiGOAGrw7fE7pSIKUwNQH2oLzeiE4nTWILJ2AMnDcdwFINluTCVHLC 5uiHAFE38dtTtf+q54ay4tDXuT6uLLrX0nI+e8HzmC4jf2a7yTX8nV/7k6Y9RAL5+KMX ahRNNqh75uhz12URuj9gpwTgorFuOktmHBighWmKZVMmvy9xLbmcGOTHXgE2oCW6bgEt WW8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784762062; x=1785366862; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=HNI6BG2rRalx1BcQoBnUKDa+4TlUreIqsReX1yE6FOI=; b=V0TKWjVI9RPGeY4AqZPn3H8oowr20hao7SZSfmjSdbAi+S33eLSkEp8LEcg4IUvjxa 0z77ZIr6o4JwqsKb+HcKpgZodqIbh7OvOzQqb1e/UnKm+33ImY9uV8hzanpRL/89Z0qz W1Z8/QhjOT7FlulrDNbJ5l7hf078CjcCYelMnJZOzlacMQRlI18Stq0Ylg0sj2mbDhte BKJFUmFkjKJ8L/YBCoSBGRJADNeSwjrYly8tsOdCxz6XwBaJ9vr8iO2j6Nvc41Rdgnap 3ZtiwL6VU42v5hqZ/FiSwHjFvgjVegzNEhkutOMsWWCPwJ7pMuGek7IlQ3aWJluDX60z t4sQ== X-Forwarded-Encrypted: i=1; AHgh+RpoH/FWT4NXhjymfaX/4PFylKvqOchiSbgeeyVsvC2BcQJAQGaoXvbjAreAz+z0vk7KP86zan4l1PidXBw=@vger.kernel.org X-Gm-Message-State: AOJu0Yz99oqG4/9fPYs7MvaD1iDmSpv+kaYcoLiEIGhaZZubg2Pxzzb8 tg6agrqBXleODq3EdnQo0VvT/A0568y9QQ2C0LfiCyw5i9ysO0/HbS7Vq8i+4lXCTz2GYqmjOFC h3NrRJQ== X-Received: from pgwa20.prod.google.com ([2002:a65:6554:0:b0:cbb:8579:3a63]) (user=wyihan job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:a126:b0:3b4:6a23:6ba with SMTP id adf61e73a8af0-3c44b006725mr571413637.26.1784762062177; Wed, 22 Jul 2026 16:14:22 -0700 (PDT) Date: Wed, 22 Jul 2026 23:13:11 +0000 In-Reply-To: <20260722-tdx-selftests-v14-0-15ad654a50db@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260722-tdx-selftests-v14-0-15ad654a50db@google.com> X-Developer-Key: i=wyihan@google.com; a=ed25519; pk=cRi0fKzS5BMxlHyHY2pJv3w/1zcgfYKr6EYGYppdMYc= X-Developer-Signature: v=1; a=ed25519-sha256; t=1784762054; l=1555; i=wyihan@google.com; s=20260319; h=from:subject:message-id; bh=wrBgxcBhN/sZNPJ4zdjh5E9TZDvM2h5ZX0OmgmcUlbY=; b=pXNTGhmG23eBH63uL+CND3RgVZfyXWaFctbAQm1rlxi8q9M8bq0fBhJEGtUE8Z5gi0YpU6n+x X3QsHJ5xnycBbH61MAUbN2eDF74a28NFjTpw/W/gm1ZCAXb5BZVZ3dR X-Mailer: b4 0.14.3 Message-ID: <20260722-tdx-selftests-v14-6-15ad654a50db@google.com> Subject: [PATCH v14 06/22] tools: include: Add kbuild.h for assembly structure offsets From: Lisa Wang To: Andrew Jones , Ackerley Tng , Binbin Wu , Chao Gao , Chenyi Qiang , Dave Hansen , Erdem Aktas , Ira Weiny , Isaku Yamahata , Kiryl Shutsemau , linux-kselftest@vger.kernel.org, Paolo Bonzini , "Pratik R. Sampat" , Reinette Chatre , Rick Edgecombe , Roger Wang , Ryan Afranji , Sagi Shahar , Sean Christopherson , Shuah Khan , Xiaoyao Li , Oliver Upton Cc: Jeremiah McReynolds , kvm@vger.kernel.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, x86@kernel.org, Lisa Wang Content-Type: text/plain; charset="utf-8" From: Sagi Shahar Add the Kbuild macros needed to enable the filechk_offsets mechanism to generate C header files containing structure member offset information. Tools depending on assembly code that operate on structures have to hardcode the offsets of structure members. The Kbuild infrastructure can instead generate C header files with these offsets automatically, allowing them to be included in assembly code as symbolic constants. For example, the TDX guest boot code requires access to parameters passed in the C structure (struct td_boot_parameters). This header provides the macros needed to extract these offsets from C code and expose them to assembly, ensuring the two remain synchronized. Signed-off-by: Sagi Shahar Reviewed-by: Ira Weiny Signed-off-by: Lisa Wang Reviewed-by: Binbin Wu --- tools/include/linux/kbuild.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tools/include/linux/kbuild.h b/tools/include/linux/kbuild.h new file mode 100644 index 000000000000..957fd55cd159 --- /dev/null +++ b/tools/include/linux/kbuild.h @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __TOOLS_LINUX_KBUILD_H +#define __TOOLS_LINUX_KBUILD_H + +#define DEFINE(sym, val) \ + asm volatile("\n.ascii \"->" #sym " %0 " #val "\"" : : "i" (val)) + +#define OFFSET(sym, str, mem) \ + DEFINE(sym, __builtin_offsetof(struct str, mem)) + +#endif /* __TOOLS_LINUX_KBUILD_H */ -- 2.55.0.229.g6434b31f56-goog