From patchwork Wed Jan 31 16:53:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 126371 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp906102ljc; Wed, 31 Jan 2018 08:56:04 -0800 (PST) X-Google-Smtp-Source: AH8x226V6mvEBu0hXq9VAkTPuNdcrLJacfG7JCUmih56H8LlJIujcGZbyGFrdLZEK0jODeelqK3+ X-Received: by 10.36.78.136 with SMTP id r130mr3116516ita.7.1517417764540; Wed, 31 Jan 2018 08:56:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517417764; cv=none; d=google.com; s=arc-20160816; b=KjHgKy4ixt0W5gNE3MOO+X6yMD1Nv1BK1eyB6YnmaeLrPBj+ic/6LZpnPPlaV+C4Pz UjEr7lvDFpcIrDRDWVsj/DxYzddlouPhgG91z+IHru7MCEyrQwG0VnhEeAhVRHvQF5gt ujkVqodj0BiZRvwi6cUQijb4GM51fwwb5lnFREDY6VCGPO5yQ3vDvMpBThwQbfKlss88 GJ1g9cYuiXNY+rNJTd+ru9lg8hYSVzDc84rHx7XdxBOXTytqtM4WgszkZvsu2IYu1IOh 8n8z1/0hJonUwE5TJOLSwxMTDT3YERGHCcJF2V/X9tcrx4OLYlo+2KpWo2ImxxDf/Yyr NoxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=Kse+5rNi/0YQl1iMfGG93CQckULyjkJpve0QDGOpv4Q=; b=bf/HT/pkBhHyT1aU6JaK0KBkZUlzWRAf8P3/ZY9Fc/hBhayn13zmngJLtNHheKH1j4 0/5/qrs7ydcYHp6Ab181MolfDk51XkciLUE6UrxBNvTHOshiMW9o+nV0BUVms4EEYmKm QKlGvcug+eaWM+HLpBOVcDCOS2njCXBPYu/rwbAQWwLZoTyEp19/DhTN3kfo8xvVNU14 aEEJwlMVzP+XpyaGr6hIksaBqP/ekt0upCz4oIfwfpzxkCCtSKhFhgbbeQB1+Ajk3vj8 taFg/n5TLHcrCihYaqStw2utavz1FHT8VurYv3KxDpU+5aWGSEnZjWnGkUSfsiWQn8yM PdQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=hytLztMP; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id o133si93037itd.110.2018.01.31.08.56.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 31 Jan 2018 08:56:04 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=hytLztMP; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1egvdt-00046G-St; Wed, 31 Jan 2018 16:53:49 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1egvds-00043x-9i for xen-devel@lists.xen.org; Wed, 31 Jan 2018 16:53:48 +0000 X-Inumbo-ID: 45084269-06a7-11e8-ba59-bc764e045a96 Received: from mail-wm0-x242.google.com (unknown [2a00:1450:400c:c09::242]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 45084269-06a7-11e8-ba59-bc764e045a96; Wed, 31 Jan 2018 17:53:33 +0100 (CET) Received: by mail-wm0-x242.google.com with SMTP id r78so373416wme.0 for ; Wed, 31 Jan 2018 08:53:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=KoqbpoQQBCRj75zpMkQ4+B8W9gHe3Bk3kL/qOXtYd04=; b=hytLztMPwD8Cc39fzudtRPZdo6hhH8cSWEa/QANi+wkfm8nbCJD755nGZ9YagoKle3 3Pl3r880Gi7hr2aa3FXTO4v280z4/AcsA/qpNfe/FJ51A5leZ1A5Qu4h0fBJyM/uXeHQ 51WhDbw2tZsbwCC0IZ5zh/0jQ0rC1jgo+TyZ0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=KoqbpoQQBCRj75zpMkQ4+B8W9gHe3Bk3kL/qOXtYd04=; b=dI3maeLdiAbZVeU8AEfi3A+5moBT/41hUvRh+Uu8cphl0VAGBOtS+QJ+GpM6K7wUOA 3nRc8i8AWulMB4RV1omRxn/6NO1hXD2mzOW8rHXdLpupFcvmqFKwdotjBlqjJjmp/HLn Mpo4ZDFJOBaB05wRHM/WTf8hHuRn69zNSJgDWE4CrY+WdVcA2hGqiHLEQwVZEUNBBO5h tw+yQUNLQyozIoWBICfXRyQPuqTiqCSvx93GC4FSIm/htDCnAwskZEYdPI3MsEdeKR7p UgSlQCJ6DyHryGSNUtgvKSl8d5TBioh8ucMituxYAJ7zYR0o1x30Q/VExZIaonHvQjLc odBA== X-Gm-Message-State: AKwxyteW9Fy6ON5qE/qBgogiUonpnFP+weAczESyAYx5JUDZLCkG3YJR qpG8cUfa+RuG0SUTIFBVVtCjeXKC8+k= X-Received: by 10.28.217.213 with SMTP id q204mr18271455wmg.154.1517417625950; Wed, 31 Jan 2018 08:53:45 -0800 (PST) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id h194sm223745wma.8.2018.01.31.08.53.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 31 Jan 2018 08:53:45 -0800 (PST) From: Julien Grall X-Google-Original-From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 31 Jan 2018 16:53:34 +0000 Message-Id: <20180131165334.23175-8-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180131165334.23175-1-julien.grall@arm.com> References: <20180131165334.23175-1-julien.grall@arm.com> Cc: sstabellini@kernel.org, Julien Grall , andre.przywara@linaro.org Subject: [Xen-devel] [PATCH v2 7/7] xen/arm32: entry: Document the purpose of r11 in the traps handler X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Julien Grall It took me a bit of time to understand why __DEFINE_TRAP_ENTRY is storing the original stack pointer in r11. It is working in pair with return_traps_entry where sp will be restored from r11. This is fine because per the AAPCS r11 must be preserved by the subroutine. So in return_from_trap, r11 will still contain the original stack pointer. Add some documentation in the code to point the 2 sides to each other. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v2: - Add Stefano's reviewed-by --- xen/arch/arm/arm32/entry.S | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/xen/arch/arm/arm32/entry.S b/xen/arch/arm/arm32/entry.S index 837f64d20d..9f68da0b98 100644 --- a/xen/arch/arm/arm32/entry.S +++ b/xen/arch/arm/arm32/entry.S @@ -136,6 +136,10 @@ trap_##trap: \ cpsie iflags; \ adr lr, return_from_trap; \ mov r0, sp; \ + /* \ + * Save the stack pointer in r11. It will be restored after the \ + * trap has been handled (see return_from_trap). \ + */ \ mov r11, sp; \ bic sp, #7; /* Align the stack pointer (noop on guest trap) */ \ b do_trap_##trap @@ -246,6 +250,10 @@ DEFINE_TRAP_ENTRY_NOIRQ(fiq) DEFINE_TRAP_ENTRY_NOABORT(data_abort) return_from_trap: + /* + * Restore the stack pointer from r11. It was saved on exception + * entry (see __DEFINE_TRAP_ENTRY). + */ mov sp, r11 ENTRY(return_to_new_vcpu32) ldr r11, [sp, #UREGS_cpsr]