From: Lorenzo Pieralisi <lorenzo.pieralisi-5wv7dgnIgG8@public.gmane.org>
To: Ard Biesheuvel <ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Cc: "linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org"
<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>,
Leif Lindholm
<leif.lindholm-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
Heyi Guo <heyi.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
Peter Jones <pjones-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
Matt Fleming
<matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>,
Hanjun Guo <hanjun.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
Bjorn Helgaas <bhelgaas-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
Subject: Re: [PATCH] efifb: avoid reconfiguration of BAR that covers the framebuffer
Date: Tue, 21 Mar 2017 15:52:51 +0000 [thread overview]
Message-ID: <20170321155251.GB4799@red-moon> (raw)
In-Reply-To: <CAKv+Gu9oLVWY4QOf=eONT6a8v1+m8BKUUR79LUamysKZhbb2CQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
On Tue, Mar 21, 2017 at 11:59:16AM +0000, Ard Biesheuvel wrote:
[...]
> >> +static void efifb_fixup_resources(struct pci_dev *dev)
> >> +{
> >> + u64 fb_base = screen_info.lfb_base;
> >> + u64 fb_size = screen_info.lfb_size;
> >> + int i;
> >> +
> >> + if (resource_found || screen_info.orig_video_isVGA != VIDEO_TYPE_EFI)
> >> + return;
> >> +
> >> + if (screen_info.capabilities & VIDEO_CAPABILITY_64BIT_BASE)
> >> + fb_base |= (u64)screen_info.ext_lfb_base << 32;
> >> +
> >> + if (!fb_base)
> >> + return;
> >> +
> >> + for (i = 0; i < PCI_STD_RESOURCE_END; i++) {
> >> + struct resource *res = &dev->resource[i];
> >> +
> >> + if (!(res->flags & IORESOURCE_MEM))
> >> + continue;
> >> +
> >> + if (res->start <= fb_base && res->end >= fb_base + fb_size) {
> >
> > You are checking for a live resource here right (ie PCI device should be
> > enabled) ? I am not sure that just checking the resource range is safe
> > (I mean it would be most certainly a FW bug to have a PCI disabled
> > device with memory BAR programmed with the FB addresses but thought it
> > was worth mentioning).
> >
>
> It is implied that the device is enabled. The GOP protocol exposes a
> live framebuffer base/size with some metadata regarding the pixel
> format/color depth etc. It contains no annotations as to whether the
> device is PCI or simply a framebuffer mapped in system memory, and so
> we can only assume that the device is enabled.
That's why I think you should actually check that the device memory
cycles are enabled to prevent setting a fixed resource for the wrong
PCI device (we could argue that would be a FW bug - better play it
safe though).
Thanks,
Lorenzo
WARNING: multiple messages have this Message-ID (diff)
From: lorenzo.pieralisi@arm.com (Lorenzo Pieralisi)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] efifb: avoid reconfiguration of BAR that covers the framebuffer
Date: Tue, 21 Mar 2017 15:52:51 +0000 [thread overview]
Message-ID: <20170321155251.GB4799@red-moon> (raw)
In-Reply-To: <CAKv+Gu9oLVWY4QOf=eONT6a8v1+m8BKUUR79LUamysKZhbb2CQ@mail.gmail.com>
On Tue, Mar 21, 2017 at 11:59:16AM +0000, Ard Biesheuvel wrote:
[...]
> >> +static void efifb_fixup_resources(struct pci_dev *dev)
> >> +{
> >> + u64 fb_base = screen_info.lfb_base;
> >> + u64 fb_size = screen_info.lfb_size;
> >> + int i;
> >> +
> >> + if (resource_found || screen_info.orig_video_isVGA != VIDEO_TYPE_EFI)
> >> + return;
> >> +
> >> + if (screen_info.capabilities & VIDEO_CAPABILITY_64BIT_BASE)
> >> + fb_base |= (u64)screen_info.ext_lfb_base << 32;
> >> +
> >> + if (!fb_base)
> >> + return;
> >> +
> >> + for (i = 0; i < PCI_STD_RESOURCE_END; i++) {
> >> + struct resource *res = &dev->resource[i];
> >> +
> >> + if (!(res->flags & IORESOURCE_MEM))
> >> + continue;
> >> +
> >> + if (res->start <= fb_base && res->end >= fb_base + fb_size) {
> >
> > You are checking for a live resource here right (ie PCI device should be
> > enabled) ? I am not sure that just checking the resource range is safe
> > (I mean it would be most certainly a FW bug to have a PCI disabled
> > device with memory BAR programmed with the FB addresses but thought it
> > was worth mentioning).
> >
>
> It is implied that the device is enabled. The GOP protocol exposes a
> live framebuffer base/size with some metadata regarding the pixel
> format/color depth etc. It contains no annotations as to whether the
> device is PCI or simply a framebuffer mapped in system memory, and so
> we can only assume that the device is enabled.
That's why I think you should actually check that the device memory
cycles are enabled to prevent setting a fixed resource for the wrong
PCI device (we could argue that would be a FW bug - better play it
safe though).
Thanks,
Lorenzo
next prev parent reply other threads:[~2017-03-21 15:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-20 22:13 [PATCH] efifb: avoid reconfiguration of BAR that covers the framebuffer Ard Biesheuvel
2017-03-20 22:13 ` Ard Biesheuvel
2017-03-21 11:54 ` Lorenzo Pieralisi
2017-03-21 11:54 ` Lorenzo Pieralisi
2017-03-21 11:59 ` Ard Biesheuvel
2017-03-21 11:59 ` Ard Biesheuvel
[not found] ` <CAKv+Gu9oLVWY4QOf=eONT6a8v1+m8BKUUR79LUamysKZhbb2CQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-21 15:52 ` Lorenzo Pieralisi [this message]
2017-03-21 15:52 ` Lorenzo Pieralisi
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=20170321155251.GB4799@red-moon \
--to=lorenzo.pieralisi-5wv7dgnigg8@public.gmane.org \
--cc=ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=bhelgaas-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
--cc=hanjun.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=heyi.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=leif.lindholm-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org \
--cc=pjones-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.