From patchwork Fri Feb 2 14:19:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 126717 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp687278ljc; Fri, 2 Feb 2018 06:21:56 -0800 (PST) X-Google-Smtp-Source: AH8x227gbwikl9DRlXxDEYW50NB/7eZrU+KPegCX+YnBDqnEt5Pf38mqDRxlr5pyM6cXHEvpQBoP X-Received: by 10.36.47.78 with SMTP id j75mr44882931itj.129.1517581316541; Fri, 02 Feb 2018 06:21:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517581316; cv=none; d=google.com; s=arc-20160816; b=eD91ojz9xADkGiWdrjLhdEmHVIGABbaaNVruWowCcRUqfPlzHBes96K+ogDX4AqI9j 6RBnITPTvdZQwECJggfkR6J8MK8Ne/VC/G07Ul5k0vloc5mek+R4XvPbl1taMKFGFO7W 5c+ZRM2jH9Sgt7MyQxl/8RZ3ljtKlRpXo7WM9opqweWcj3MTuqS9ws1uk0MrLLb+nOg5 LGBUV3pKtcZwenJ4IZNice8vnnfNA3Iw6srMDvnA7Efi9SsFILTMRFyKWwH0F02m5RRh A+UhD5vOnlsgPZvHn8v3xEbOBins0OWuSP6K5iUNVN7BimBIOfrmtlM5nfA8Nlyi7Lg5 8lag== 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=Ttb4juC7JAV1qQciqeg16WG2L+oZrW8LZHC3VirZEdw=; b=dEQZot9R7Jh34OAgZS8yRt+ml1j/HfAESuH6bmRehq+pmez91xZ6XY3LaTlmy2eoRP ND6LnR97do48wfKBOM7KGXBvayHvcHKbtYkI9hjLCkLxB601axrG0mlcnRWF5MoBYrC+ KBLKE0nv2Hh2KdjG1nRt+gnEboUdKup28SV43+mXPFGgI/hHum5rc8SUbj2IkE/RtK0a 8WGYNdPP7LytjIjtqAIv8DYe54PZGgDoLN/WCMGkLbAF5ttwThLV7had8nC5dpAwvI0C cM2JjRS8Am2KJxkvrvROAHWB1ooHNJRB8cnZV07qKxX24WZXYG3WUDVp5Yr5sgDm5y2W mTYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=FTYb+KUV; 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 q1si1870391iof.47.2018.02.02.06.21.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Feb 2018 06:21:56 -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=FTYb+KUV; 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 1ehcBm-0008AD-T9; Fri, 02 Feb 2018 14:19:38 +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 1ehcBk-00088Z-Vg for xen-devel@lists.xen.org; Fri, 02 Feb 2018 14:19:37 +0000 X-Inumbo-ID: 0da6486f-0824-11e8-ba59-bc764e045a96 Received: from mail-wm0-x243.google.com (unknown [2a00:1450:400c:c09::243]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 0da6486f-0824-11e8-ba59-bc764e045a96; Fri, 02 Feb 2018 15:19:18 +0100 (CET) Received: by mail-wm0-x243.google.com with SMTP id g1so12935035wmg.2 for ; Fri, 02 Feb 2018 06:19: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=NIrW1NDfpzkQ2CWQ3gnFC6znmev1ATxTI9Fmu/nwmNk=; b=FTYb+KUVFNZpmzkljadpaOF9fF1aTQ6IErEYmzoGw5h6rFTYh4MvpLntd4lzdP5RFl LTyAT5arbZHLZW0AAAyuTU/iowD0cmgJV47ccp5fnYxb9TpuJTqs7KYWIhmQyvgEyhuY Fth5MHDUJySfFIbVekhFA2NrtXGK+tAhnIDmo= 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=NIrW1NDfpzkQ2CWQ3gnFC6znmev1ATxTI9Fmu/nwmNk=; b=mGzKMVqWk9T+T7ubJDb4gDAvJiIN9i2Gu72s3zxF2V/mseaxTdwYdu7UZ1UJVePTlB A94w+V735NoP7whSczN6SyQHwRibN5Rbm8Y+duw7PJTtVDJ+bmdKOxNLL6hHNxhJ2MzV hyGGpsPJN76RHfsdI/53WVGkGVCqXN6jdgcm6DWg214HH/IMU7Yl7v5/D53Vn32sCaK7 t3r/pIrBlx6jya/pZ9Dr+OGB3xAlzSGa06Tw6Q34TyT41fcC6heHF92yPv8pAs8tpca+ fABqB2R4yCs2p0J/7nnzQF+/3DdBqJeAiW12Y+Nz7U2fyFv5x+jLEsMqMRR/YUOhrAeU 1SJg== X-Gm-Message-State: AKwxytd37BSThbdHAN3TzrIclC4uIomxfxBVUkt3A2KcwoKk/FEnbf0v w2OHhz3J79htdxOrj2LYTXwFH65tGjk= X-Received: by 10.28.185.196 with SMTP id j187mr32990644wmf.94.1517581174162; Fri, 02 Feb 2018 06:19:34 -0800 (PST) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id u79sm3057422wma.10.2018.02.02.06.19.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Feb 2018 06:19:33 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Fri, 2 Feb 2018 14:19:25 +0000 Message-Id: <20180202141925.19387-8-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180202141925.19387-1-julien.grall@linaro.org> References: <20180202141925.19387-1-julien.grall@linaro.org> Cc: sstabellini@kernel.org, Julien Grall , andre.przywara@linaro.org Subject: [Xen-devel] [PATCH v4 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 --- 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 2f8b7cb7b8..f6908e3f16 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 @@ -229,6 +233,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]