From: Stefan Berger <stefanb@linux.ibm.com>
To: Cornelia Huck <cohuck@redhat.com>,
eric.auger@redhat.com,
Alex Williamson <alex.williamson@redhat.com>
Cc: eric.auger.pro@gmail.com, qemu-devel@nongnu.org,
stefanb@linux.vnet.ibm.com, f4bug@amsat.org
Subject: Re: [PATCH v4] vfio/common: remove spurious tpm-crb-cmd misalignment warning
Date: Fri, 6 May 2022 08:40:01 -0400 [thread overview]
Message-ID: <606aa970-fc6c-8e1e-ffad-a6e5fe845c47@linux.ibm.com> (raw)
In-Reply-To: <875ymj5d2z.fsf@redhat.com>
On 5/6/22 03:34, Cornelia Huck wrote:
> On Fri, May 06 2022, Eric Auger <eric.auger@redhat.com> wrote:
>
>> Hi Alex,
>>
>> On 4/28/22 22:14, Alex Williamson wrote:
>>> On Thu, 28 Apr 2022 15:49:45 +0200
>>> Eric Auger <eric.auger@redhat.com> wrote:
>
>>>> +static bool vfio_known_safe_misalignment(MemoryRegionSection *section)
>>>> +{
>>>> + MemoryRegion *mr = section->mr;
>>>> +
>>>> + if (!TPM_IS_CRB(mr->owner)) {
>>>> + return false;
>>>> + }
>>> It looks like this test is going to need to be wrapped in #ifdef
>>> CONFIG_TPM:
>>
>> sorry for the delay. Your message fell though the cracks :-(
>>
>> if I put an '#ifdef CONFIG_TPM' I need to inverse the logic because by
>> default the function shall return false.
>>
>> solution #1
>>
>> #ifdef CONFIG_TPM
>> if (TPM_IS_CRB(mr->owner)) {
>>
>> /* this is a known safe misaligned region, just trace for debug purpose */
>> trace_vfio_known_safe_misalignment(memory_region_name(mr),
>> section->offset_within_address_space,
>> section->offset_within_region,
>> qemu_real_host_page_size());
>>
>> return true;
>> }
>>
>> #endif
>> return false;
>>
>> This looks weird to me.
>>
>> + if (!object_dynamic_cast(mr->owner, TYPE_TPM_CRB)) {
>> + return false;
>> + }
>>
>>
>> solution #2
>> replace !object_dynamic_cast(mr->owner, TYPE_TPM_CRB) by
>> !object_dynamic_cast(mr->owner, "tpm-crb")
>> and add a comment saying that we don't use TYPE_TPM_CRB on purpose
>>
>> solution #3
>> Move #define TPM_IS_CRB(chr) and related defined out of
>> #ifdef CONFIG_TPM hoping it does not have other side effects
>>
>> Thoughts?
>> Eric
>
> solution #4
>
> #ifndef CONFIG_TPM
> /* needed for an alignment check in non-tpm code */
> static inline Object *TPM_IS_CRB(Object *obj)
> {
> return NULL;
> }
> #endif
>
> I think it would be good if we could hide the configuration details in
> the header.
>
Solution #4 looks good to me...
prev parent reply other threads:[~2022-05-06 12:47 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-28 13:49 [PATCH v4] vfio/common: remove spurious tpm-crb-cmd misalignment warning Eric Auger
2022-04-28 13:58 ` Cornelia Huck
2022-04-28 20:14 ` Alex Williamson
2022-05-06 7:05 ` Eric Auger
2022-05-06 7:34 ` Cornelia Huck
2022-05-06 7:49 ` Eric Auger
2022-05-06 7:56 ` Cornelia Huck
2022-05-06 12:40 ` Stefan Berger [this message]
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-all 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=606aa970-fc6c-8e1e-ffad-a6e5fe845c47@linux.ibm.com \
--to=stefanb@linux.ibm.com \
--cc=alex.williamson@redhat.com \
--cc=cohuck@redhat.com \
--cc=eric.auger.pro@gmail.com \
--cc=eric.auger@redhat.com \
--cc=f4bug@amsat.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanb@linux.vnet.ibm.com \
/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;
as well as URLs for NNTP newsgroup(s).