public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: Pete Batard <pete@akeo.ie>
Cc: "edk2-devel@lists.01.org" <edk2-devel@lists.01.org>,
	"Gao, Liming" <liming.gao@intel.com>
Subject: Re: [PATCH v3 4/6] ArmPkg/Library/CompilerIntrinsicsLib: Enable VS2017/ARM builds
Date: Thu, 14 Dec 2017 15:05:14 +0100	[thread overview]
Message-ID: <CAKv+Gu-OaiaZG8XJmhW_0X0YqRL1J4d7X0vMtxWpr1+VpuTuWw@mail.gmail.com> (raw)
In-Reply-To: <bd83f8b5-7812-d2a5-875d-66921a1561d0@akeo.ie>

On 13 December 2017 at 14:56, Pete Batard <pete@akeo.ie> wrote:
> Hi Ard. Thanks for reviewing this.
>
> On 2017.12.12 19:59, Ard Biesheuvel wrote:
>>>
>>> +  EXPORT _fltused
>>> +  EXPORT __brkdiv0
>>> +
>>
>>
>> Why are these being exported? Are these part of the CRT ABI?
>
>
> Good point. I exported them because I was encountering undefined symbols for
> those when I started working on adding ARM support. But I now suspect they
> may have come from an export statement from VS headers (which we no longer
> include), as re-test shows that the exports seem to be superfluous.
>
> I will test further to confirm that this is the case, and remove the
> unneeded exports.
>
>>> +__brkdiv0
>>> +    udf #249
>>> +
>>
>>
>> This will cause a crash when invoked, in a way that gives very little
>> to go on to figure out what happens.
>
>
> Yes. I mostly copied what ReactOS was doing here, since it should be similar
> to what Microsoft does internally.
>
>> Perhaps branch to a C function
>> here that calls ASSERT() and CpuDeadLoop ?
>
>
> I don't mind giving it a try, if we keep the separate .asm files for MSVC.
>
> On the other hand, if I am to try to reuse existing assembly, as you suggest
> below, then I don't think I want to introduce anything that will differ from
> how divisions by zero are currently handled there. As far as I can tell (for
> RVCT, which is the only assembly that might be suitable for reuse with MSFT)
> the current way of handling a zero divisor is to set result and remainder to
> 0 and return (as per uldiv.asm). For gcc, we also have the following comment
> in div.S:
>
>   "@ What to do about division by zero?  For now, just return."
>
> So, while I agree that calling ASSERT and CpuDeadLoop is probably the better
> approach, I'd rather have the introduction of this behaviour be the subject
> of a separate ARM harmonization patch, that applies to all the toolchains,
> rather than something that's specific to Visual Studio usage.
>

I agree. Reusing code is more important than having one flavour of
division that will spot div-by-0. But we really don't want the UDF,
because it will crash unconditionally without a hint of what happened.

>> There are many different division implementations already in the same
>> directory. Do we really need a new one?
>
>
> I'll look into that. My goal with this series was to make sure that the
> changes being introduced would not break existing toolchains, which is why I
> saw it preferable to keep the MSVC intrinsics separate.
>
> Now, gcc assembly is not something that can be reused easily with the MS
> toolchain, so the only possibility are the RVCT .asm files.
>
> There's a fair bit of work involved into trying to figure out if and how we
> can reuse that code, but I'll see what I can do. It'll probably be a few
> weeks before I get back to this list on that however.
>

I'm prepared to be pragmatic here. I would prefer to have all
platforms run the same low level division code, but I understand that
it is tightly coupled to the compiler, given that they are intrinsics.

So yes, please try to reuse the RVCT code if feasible without a ton of
rework, but it seems like we will need to live with some MSFT specific
hooks anyway (if I understand the prototypes correctly)


  reply	other threads:[~2017-12-14 14:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-08 14:06 [PATCH v3 0/6] Add ARM support for VS2017 Pete Batard
2017-12-08 14:06 ` [PATCH v3 1/6] MdePkg: Disable some Level 4 warnings for VS2017/ARM Pete Batard
2017-12-08 14:06 ` [PATCH v3 2/6] MdePkg/Library/BaseStackCheckLib: Add Null handler " Pete Batard
2017-12-08 14:06 ` [PATCH v3 3/6] MdePkg/Library/BaseLib: Enable VS2017/ARM builds Pete Batard
2017-12-08 14:06 ` [PATCH v3 4/6] ArmPkg/Library/CompilerIntrinsicsLib: " Pete Batard
2017-12-10 13:30   ` Gao, Liming
2017-12-12 19:59   ` Ard Biesheuvel
2017-12-13 13:56     ` Pete Batard
2017-12-14 14:05       ` Ard Biesheuvel [this message]
2017-12-08 14:06 ` [PATCH v3 5/6] MdePkg/Include: Add VA list support for VS2017/ARM Pete Batard
2017-12-08 14:06 ` [PATCH v3 6/6] BaseTools/Conf: Add VS2017/ARM support Pete Batard
2017-12-08 14:13 ` [PATCH v3 0/6] Add ARM support for VS2017 Gao, Liming

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAKv+Gu-OaiaZG8XJmhW_0X0YqRL1J4d7X0vMtxWpr1+VpuTuWw@mail.gmail.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox