[flashrom] Porting flashrom to OpenBSD

Carl-Daniel Hailfinger c-d.hailfinger.devel.2006 at gmx.net
Fri Jun 25 17:10:09 CEST 2010


On 25.06.2010 16:44, Theo de Raadt wrote:
>> On 2010/06/25 08:32, Theo de Raadt wrote:
>>     
>>>>> you're in CC of this mail because you sent the "unbreak pciutils" mail
>>>>> to this list, and the failure mode is related.
>>>>> http://marc.info/?l=openbsd-ports&m=126918139214769
>>>>>           
>>>> Hmmm... So why is PCIOCWRITE failing, even when securelevel is 0 and 
>>>> allowaperture=2...
>>>>
>>>> I don't know this area at all well, but this looks worth investigating
>>>>
>>>> /sys/dev/pci/pci.c
>>>>
>>>>         case PCIOCWRITE:
>>>>                 io = (struct pci_io *)data;
>>>>                 switch (io->pi_width) {
>>>>                 case 4:
>>>>                         /* Make sure the register is properly aligned */
>>>>                         if (io->pi_reg & 0x3)
>>>>                                 return EINVAL;
>>>>                         pci_conf_write(pc, tag, io->pi_reg, io->pi_data);
>>>>                         error = 0;
>>>>                         break;
>>>>                 default:
>>>>                         error = ENODEV;
>>>>                         break;
>>>>                 }
>>>>                 break;
>>>>
>>>>         
>>>>> Thanks, looks good. One small comment about installation in sbin,
>>>>> though. flashrom can also work with programmers attached to serial ports
>>>>> and USB, and those might work even for non-root users if appropriate
>>>>> permissions are set (well, under most Unix-like OS, but OpenBSD might be
>>>>> different). Due to that, some people think installing in bin instead of
>>>>> sbin makes more sense.
>>>>>           
>>>> I don't think the location is a problem..
>>>>
>>>>         
>>>>> Stuart, does the pcilib abort happen on i386 and amd64?
>>>>>           
>>>> I don't have an i386 box handy to try at the moment.
>>>>         
>>> The aperture is for X.  Only one use at a time is permitted.
>>>       
>> I should have mentioned, this was single-user.
>>     
>
> The aperture is for X.

I think I should clarify a bit what flashrom (BIOS/EFI/optionROM
flasher) does/needs.

PCI config space writes (usually only to the PCI<->LPC bridge) are
needed to tell that bridge to enable pass through for flash chip accesses.
I/O port access is needed on some chipsets which have the passthrough
enable in I/O space instead of PCI config space.
Raw memory access is needed to the top 16 MB of the 32bit address space
because that's where the BIOS flash ROM chip is mapped on i386/amd64,
and to access the SPI flash ROM controller MMIO regions (somewhere in
the address space, needs to be determined from PCI config space
registers) on most chipsets released in the last 4 years.

flashrom accesses PCI config space read/write via pciutils/libpci which
uses /dev/pci AFAICS. The problem flashrom has right now is that PCI
config writes via /dev/pci don't work. Without PCI config space write
access, everything else is sort of pointless (you won't have access to
the flash chip).

Some people use flashrom to read out the flash chip and check it for
malware, and I heard that's one of the motivations (well, besides BIOS
updates) for trying to get it working on OpenBSD.

Regards,
Carl-Daniel




More information about the flashrom mailing list