From patchwork Fri Jan 19 13:41:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 125255 Delivered-To: patch@linaro.org Received: by 10.46.66.141 with SMTP id h13csp436621ljf; Sat, 20 Jan 2018 13:28:32 -0800 (PST) X-Google-Smtp-Source: AH8x22743wgBgHmG68Tlr83h/qqYzd5ZA1xgY3+XL5sIDqss4tFr+BCzJuhBgRHkkBxNM/Ji9PXl X-Received: by 10.107.133.163 with SMTP id p35mr3037750ioi.44.1516483712726; Sat, 20 Jan 2018 13:28:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516483712; cv=none; d=google.com; s=arc-20160816; b=s2dOMwpuf8SZ2/zVP6ZtX87lOFyAtFYU66W9qD24nmr1Cu3UczC1c+uu2p7wm/l517 7QBYEowgHq8P1AkKeixkGioBlDwbpiKlqjO83TGbHYMyilhQLBOGUznaz5600ZdFdLjz p/sOmJulYuMVUwsarY6m0saRr8OIoh2uRL1Th0eLYwudEKH8K3l5WCEOwakvIxhUd7oW EAEHsy+pjQSCRSpyYw4l4pqiY/BlJ/TPHuU4ObsUGFkkQRAwnZrk/i05cG36K/60x1wq SwsQS4ximcmNwdHrzgb0W4FZu1d5R3Qqv89e+B3SsyEdnfA+6xE+DNzIgnUt2Rs9rzpC MsjA== 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=DwPcjAn0da1qt+jUEicZizmhuY0n85tV/u0gXZFIQ34=; b=wWg8t8Py/eEuZDu8faKoItIGtQUjb0TLA62FfkIRTo6FqH3jpMbZwxNkWMgOtyjF00 A0pGCTznAxK3dtPrQmJBNnan+ulPjjsG0Ne9plkJcNRmgmdCOiFioVfwEk29rbj6CbKL jBalSk0NZLAMQKaWJtwSRk0py/S1duVWvBYuFbhoR1Cw9G4owj/rAYkNG2nnJ99hu8VX wtbLMarRXtKMviKzcdrYAjKMpo2aUuetWj713+bRdFXnIQmbDAQY5TIShR4FiS1/B1sL SILRgHzm0/GhFWJkkLiSLDhOe4hp+1SZ1VqYKgwlw/N8nlFcKMNoVCypiCvitpSHsesL HDfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=QEGlffBp; 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 i190si3391319itg.13.2018.01.20.13.28.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 20 Jan 2018 13:28:32 -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=QEGlffBp; 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 1ed0dz-0007KJ-0Z; Sat, 20 Jan 2018 21:25:43 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ed0dy-0007KD-Bj for xen-devel@lists.xen.org; Sat, 20 Jan 2018 21:25:42 +0000 X-Inumbo-ID: d46ced41-fe28-11e7-b0d7-9f685aff125f Received: from mail-wm0-f67.google.com (unknown [74.125.82.67]) by us1-amaz-eas1.inumbo.com (Halon) with ESMTPS id d46ced41-fe28-11e7-b0d7-9f685aff125f; Sat, 20 Jan 2018 21:28:17 +0000 (UTC) Received: by mail-wm0-f67.google.com with SMTP id b141so9638787wme.1 for ; Sat, 20 Jan 2018 13:25:35 -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=ndD4Cyhh+hJQe/eNI/MygqK4VBjp1r9v0wZNTSBrBKc=; b=QEGlffBpB3o4mJ4afQCR4rcpaga00KuDN/oXe4Hsb7Ya6vwUo1/fJ9kwdOxy/OHmnd ghFL80GRfB8pqdHIjqcLa8BtDXmnulUZPftzpgLFlAurdU7uX3QO8FDzdEHieFHxsSHw /mDb7drqKgGWfrQbRyQoZ1Pr7SsqR086xtnhk= 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=ndD4Cyhh+hJQe/eNI/MygqK4VBjp1r9v0wZNTSBrBKc=; b=Qnb8A1iLaVXBxAilpfuDjROx0q1gS3RgxV7V+8qo77K8crSsAGEr4wmRKXr4qRq12F Qfnm3srUTfM2apbg21XdvsN/xsEKRg4R6kuX88DJp1P7knky3Wy/Ss2xem7uCywjSlUe 2VM92ATl3C/ZySLKSUhShPs4Eq6JmIXXlK/AeRomhnrlcnShL9Vzj1jIOCnxqurBDFLo N3BwAhtCyzqEVL4vuJS2Pp1axaNZcJ81/6oCbLc/s0uV3QAViDR7du8C3XOT4ad4FDne 9OqEnG83sy8vcxOe6CmTSws9+xN6Tz7Qdkwn86Tn2nzp8/jHJGVmEqEsxu9yMCKL6RfG PwJw== X-Gm-Message-State: AKwxyte3jWRmot/KhWT2a8964idpeSxew0bLTbABtQojqjIbg+jHJXbv /BKiBs4KQYolkcp7YRmJn4Kb07KqgSY= X-Received: by 10.28.236.24 with SMTP id k24mr8411609wmh.8.1516369271464; Fri, 19 Jan 2018 05:41:11 -0800 (PST) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id s44sm5113642wrc.64.2018.01.19.05.41.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Jan 2018 05:41:10 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Fri, 19 Jan 2018 13:41:03 +0000 Message-Id: <20180119134103.3390-8-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180119134103.3390-1-julien.grall@linaro.org> References: <20180119134103.3390-1-julien.grall@linaro.org> Cc: sstabellini@kernel.org, andre.przywara@linaro.org Subject: [Xen-devel] [PATCH 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" 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 --- 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 c529592d20..7f323de484 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]