From patchwork Thu Nov 14 09:08:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 13874757 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C17BAD65C60 for ; Thu, 14 Nov 2024 09:08:34 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.836110.1251983 (Exim 4.92) (envelope-from ) id 1tBVpu-0003x6-5o; Thu, 14 Nov 2024 09:08:22 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 836110.1251983; Thu, 14 Nov 2024 09:08:22 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tBVpu-0003vr-24; Thu, 14 Nov 2024 09:08:22 +0000 Received: by outflank-mailman (input) for mailman id 836110; Thu, 14 Nov 2024 09:08:20 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tBVps-0003tk-PZ for xen-devel@lists.xenproject.org; Thu, 14 Nov 2024 09:08:20 +0000 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [2a00:1450:4864:20::630]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id fb92da40-a267-11ef-99a3-01e77a169b0f; Thu, 14 Nov 2024 10:08:15 +0100 (CET) Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-a9ed49edd41so61997966b.0 for ; Thu, 14 Nov 2024 01:08:15 -0800 (PST) Received: from andrewcoop.eng.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa20e046ea8sm38491166b.169.2024.11.14.01.08.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Nov 2024 01:08:13 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: fb92da40-a267-11ef-99a3-01e77a169b0f X-Custom-Connection: eyJyZW1vdGVpcCI6IjJhMDA6MTQ1MDo0ODY0OjIwOjo2MzAiLCJoZWxvIjoibWFpbC1lajEteDYzMC5nb29nbGUuY29tIn0= X-Custom-Transaction: eyJpZCI6ImZiOTJkYTQwLWEyNjctMTFlZi05OWEzLTAxZTc3YTE2OWIwZiIsInRzIjoxNzMxNTc1Mjk1Ljk0NDMzOSwic2VuZGVyIjoiYW5kcmV3LmNvb3BlckBjbG91ZC5jb20iLCJyZWNpcGllbnQiOiJ4ZW4tZGV2ZWxAbGlzdHMueGVucHJvamVjdC5vcmcifQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1731575295; x=1732180095; darn=lists.xenproject.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=YfpsIkdC3S7Mxflt2zA8gCdCUNbi3Zq3guME8F7/d90=; b=RUEQ1V1ABQ11VsQMihhsRit0snTzuSDOaeDSjdacXCCUkQA4oxi/EFJNDM4g3+fSwA 9s4i9J/TCFnypX/nFf35jhaldAG30c9IjpdKsmJ2yMh9u9LyDzyT2VMKED+de2aXg/p5 10VU9NSuvLc3kuS4wWj+fqfeGBj2AgVjMUH3I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731575295; x=1732180095; 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=YfpsIkdC3S7Mxflt2zA8gCdCUNbi3Zq3guME8F7/d90=; b=jV+NLnnyY+AfYLihsP5iH7+SHrRIevHGTDURxqgJ5QFg4/fvS5ErvwH3E21fPz2LPV SrNykSWra3nifDZ4ZIfnzzN9xxeweD2g2NQbUp9153WH+h9xMe8JXcaV8urhycmrnRQO DEaH0v+IxgH85OhPMewhkwflTfeqIUkbc2HHtbs0CJmkXLxjHTTnUE4aVChmV+Z0WO4s UZevXTfGJJL3pmA2RA/i91qGesBuNzolMVtrBMt1leVdRzqL2Ih76NKjz62BAndJpmAD WUO6qPNMjJTEspV2wcxui2IdQqTC9AH1Ekj+G0qMpwmvRk/H6DgVuIakr3WSLKwu91Xz XoIQ== X-Gm-Message-State: AOJu0Yy+Kzw6wconjMwnpHjonQdQn5v0Ry2ELyo3zcxgvYFJ30JOMgEX 6ew5lIbCpvLZm+cJdugh2lfQ4FPAPw11jax/FAyTirYJJTX55IV6VXySBWbRvGtJUZply05v5/E p X-Google-Smtp-Source: AGHT+IEcMV+usM6DD7OzaUcJ3UTsg023QCtvKHrHbKhHJyEa5pTLHcXjte/ND5KIDKEKQb8TGmE1bA== X-Received: by 2002:a17:907:3e02:b0:a99:4261:e9f7 with SMTP id a640c23a62f3a-a9eefff12ddmr2107816666b.39.1731575294863; Thu, 14 Nov 2024 01:08:14 -0800 (PST) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Daniel P . Smith" , Frediano Ziglio , Alejandro Vallejo Subject: [PATCH v2 1/4] x86/trampoline: Check the size permanent trampoline at link time Date: Thu, 14 Nov 2024 09:08:07 +0000 Message-Id: <20241114090810.1961175-2-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241114090810.1961175-1-andrew.cooper3@citrix.com> References: <20241114090810.1961175-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 This is a little safer than leaving it to hope. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monné CC: Daniel P. Smith CC: Frediano Ziglio CC: Alejandro Vallejo v2: * New. --- xen/arch/x86/boot/trampoline.S | 2 ++ xen/arch/x86/xen.lds.S | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/xen/arch/x86/boot/trampoline.S b/xen/arch/x86/boot/trampoline.S index b8ab0ffdcbb0..55e4a3e402f7 100644 --- a/xen/arch/x86/boot/trampoline.S +++ b/xen/arch/x86/boot/trampoline.S @@ -161,6 +161,8 @@ GLOBAL(trampoline_cpu_started) .equ wakeup_stack, trampoline_start + PAGE_SIZE .global wakeup_stack +LABEL(trampoline_perm_end, 0) + /* From here on early boot only. */ .code32 diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S index 35693f6e3380..221fc2ef3f35 100644 --- a/xen/arch/x86/xen.lds.S +++ b/xen/arch/x86/xen.lds.S @@ -410,6 +410,13 @@ ASSERT(!SIZEOF(.plt), ".plt non-empty") ASSERT(!SIZEOF(.rela), "leftover relocations") #endif +/* + * The permanent trampoline resides in a single 4k page. Placement logic + * takes care to ensure that trampoline_phys is page aligned. + */ +ASSERT((trampoline_perm_end - trampoline_start) <= PAGE_SIZE, + "Permentant trampoline too large") + ASSERT((trampoline_end - trampoline_start) < TRAMPOLINE_SPACE - MBI_SPACE_MIN, "not enough room for trampoline and mbi data") ASSERT((wakeup_stack - wakeup_stack_start) >= WAKEUP_STACK_MIN,