From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::444; helo=mail-wr1-x444.google.com; envelope-from=leif.lindholm@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B0D242119C8B1 for ; Wed, 12 Dec 2018 06:41:17 -0800 (PST) Received: by mail-wr1-x444.google.com with SMTP id p4so17939026wrt.7 for ; Wed, 12 Dec 2018 06:41:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=hqzzHvBOIofAjX+SRk2MwIXH9nl2PPTmXCYQhtWNyOA=; b=Fm7IIyvFqqfurv1c2ax/IWC46ocOYFUw3DvgIQUclYW3HopPng4vL/xFtgbh56pLPQ mYtGNADDCeHNuQpWzdRAN22L4GMNw5HfMdm6adgjInby+0JHFLQxC+haxra63rQAIOp9 IS0bBOuzna4IjbWno/KOCvbNRaaAsAuTTpr+8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=hqzzHvBOIofAjX+SRk2MwIXH9nl2PPTmXCYQhtWNyOA=; b=gRxj4g6w0qYMRIHjCoQN+k1GdC/voWCjxex6Dn80Y1uJgDzBsAWXK9Lq9oy3E31gjo M9kVUrnkhojY4Ay+cTUX9TCnzDmAIIwUkAKkVWK4y6Hv29PErMdhRRQwguOF5NTeeKNK yQUKnmudXfRgvdCFgIQDUB8F2P/Z1lUZzrjb7EgdWEZPz0+LOXKr8VlNwaiRekWZShEB EZEB4f3iaf7+N7EZaMz+G8XmCZvYAslVixxO8JgvLBfGTOSSq46sTGk6O2HGatfvyTZm 1s2Rr4vq1IJbXPhB4JnlVlD9YRVkLXSQzhBc+1VmBOPJqRrTWvZj/OcRQLXNo9/zqB4a imqQ== X-Gm-Message-State: AA+aEWYy/8Ka/1pFF9w/2RMRqbciJ6nMzbCfEVtc987kd9CWORn/8Qks /Wy8tgT/Eu4PSHTl9CWVUaupXQ== X-Google-Smtp-Source: AFSGD/VedyAEjryury7UBdY73ITZ0BWFsrjf381qJkL8d/LHGQmBxLHPcBD3ruD1hbKg+KXVFZt6mw== X-Received: by 2002:a5d:4e82:: with SMTP id e2mr17029505wru.291.1544625675532; Wed, 12 Dec 2018 06:41:15 -0800 (PST) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id d16sm5655726wru.52.2018.12.12.06.41.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 12 Dec 2018 06:41:14 -0800 (PST) Date: Wed, 12 Dec 2018 14:41:13 +0000 From: Leif Lindholm To: Ard Biesheuvel Cc: "edk2-devel@lists.01.org" Message-ID: <20181212144113.dxrno2cpclyszjrq@bivouac.eciton.net> References: <20181212091211.13258-1-ard.biesheuvel@linaro.org> <20181212113009.vmsv37swaui3z4os@bivouac.eciton.net> <20181212123137.bzwi46gsszljlsvw@bivouac.eciton.net> MIME-Version: 1.0 In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [PATCH] EmbeddedPkg/GdbDebugAgent ARM: use modern dialect for ldm/stm instructions X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Dec 2018 14:41:18 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Dec 12, 2018 at 01:45:17PM +0100, Ard Biesheuvel wrote: > > > > > @@ -198,9 +199,9 @@ ASM_PFX(AsmCommonExceptionEntry): > > > > > and R3, R1, #0x1f @ Check CPSR to see if User or System Mode > > > > > cmp R3, #0x1f @ if ((CPSR == 0x10) || (CPSR == 0x1df)) > > > > > cmpne R3, #0x10 @ > > > > > - stmeqed R2, {lr}^ @ save unbanked lr > > > > > + stmdaeq R2, {lr}^ @ save unbanked lr > > > > Then again, looking closer at these instructions, they're not really > > doing stack operations. Just (ab)using the instruction to get at the > > banked User mode LR from a different mode. So > > a) The symmetry thing doesn't really apply, so the ED is actively > > misleading here. > > b) This could trivially be changed to use FD anyway, just setting R2's > > offset from PC to #0x34 :) > > > > Actually, since there is no writeback, what is the point of the > decrement-after? Can't we just drop it? Possibly picked specifically to _not_ be mistaken for a stack operation. In this scenario The DA just means don't add 4 to R2 before using it as address. > The more I look at this code the more broken it seems. I'll just remove it. As previously stated, I'm happy with this. / Leif > > > > > @ else > > > > > - stmneed R2, {lr} @ save SVC lr > > > > > + stmdane R2, {lr} @ save SVC lr > > > > > > > > > > > > > > > ldr R5, [SP, #0x58] @ PC is the LR pushed by srsfd > > > > > @@ -245,9 +246,9 @@ GdbExceptionHandler ( > > > > > and R1, R1, #0x1f @ Check to see if User or System Mode > > > > > cmp R1, #0x1f @ if ((CPSR == 0x10) || (CPSR == 0x1f)) > > > > > cmpne R1, #0x10 @ > > > > > - ldmeqed R2, {lr}^ @ restore unbanked lr > > > > > + ldmibeq R2, {lr}^ @ restore unbanked lr > > > > > @ else > > > > > - ldmneed R3, {lr} @ restore SVC lr, via ldmfd SP!, {LR} > > > > > + ldmibne R3, {lr} @ restore SVC lr, via ldmfd SP!, {LR} > > > > > > > > > > ldmfd SP!,{R0-R12} @ Restore general purpose registers > > > > > @ Exception handler can not change SP > > > > > -- > > > > > 2.19.2 > > > > > > > > > c) But given a), I would take this one if the comment was updated to > > be explicit about how esoteric this operation really is. > > I.e.: "(ab)use STM^ to save banked User mode LR from SVC/HYP mode" > > and "(ab)use LDM^ to restore banked User mode LR from SVC/HYP mode" > > > > I would also be happy to nuke it (including the commented out > > inclusion for BeagleBoardPkg). > > > > / > > Leif