From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=google.com (client-ip=2a00:1450:4864:20::52c; helo=mail-ed1-x52c.google.com; envelope-from=osk@google.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="BC4RHj99"; dkim-atps=neutral Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 46Tkv23cZwzF4YV for ; Fri, 13 Sep 2019 02:36:59 +1000 (AEST) Received: by mail-ed1-x52c.google.com with SMTP id c20so15528113eds.1 for ; Thu, 12 Sep 2019 09:36:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=jliOy6yIpOYYHkqndFE7UNJkAhGTFKyP9I/RLO49/6o=; b=BC4RHj99zywNv0VTqgsOrbZRmHtHsPLW3u9QNIsLvMm/fIdrG+WrmjQdU74c79fWvU Cp07ijKg0FJOYI7LHcGgPRy3pv1TR0ibg09cNfOw/8nhsXqL5GXk2vPGEm7xDFqhkQe9 erd4vhYOyRWYLu+L04GEzlJpk5iBTYtMv2yLWS2j5cFP5ZPrFZmePhsA13/RtVPfZtvv lCReeW5I2OnUOMnrGKRnoiAlp+A7vfSBo4ZMNCWHwmeb/4Pr8FojZtc2fC8CxYtA0lJb eT96HPcgpM1HPpSw1+D3kdnPTeKdI4AvIlzAlfw5VjlstCFU832NHVlHW8/Gbns6wBkH Dr6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=jliOy6yIpOYYHkqndFE7UNJkAhGTFKyP9I/RLO49/6o=; b=e5v+pFOSTAQMhLmmVDpt3Onnvrg+qe2hiHdxB+hqJDgmbqfgTUMbBokkke6jLH00Gv LBAxDHkES6FFwhPUAD4btmyWUTeu8Zj2rY8oIuKHhVrGTebFM5WJHz01EhEwu0FluuA0 Wszs9XRRjPVdKgiKjBpmS4W2SShGF4IUmWWEFsy7E4e+N0+jKNzrsoao7VOFBUFtjTvW V1wJF1EFZXHIZlMVTi6jiWsMCcdgHNpTmoGhoGlPLk/qUh1cwFpbJ8alnk0mvOzl3xeR lcAjApcNetYC96unFkzBR3km/4VS6cKgP1rpqv1286ErOMRJ52On47Lp4aUsIh5h20Lp qovA== X-Gm-Message-State: APjAAAVDjojGvpq9PF9jqVJ3x+FVLOGAt7VCdfUEWZ3JKhVV61KrbsZI v7JQuV7m8oaqHC/CRfeDjfdHvv/e1Do+QEyXnu+y6w== X-Google-Smtp-Source: APXvYqykjzZ8lDPC7o9I3DPlfOFxuHGOJuYZGH1nPZi6Z/OEdhpZ0eT5daMIwRkaz/CCHQslqD7qHGY+drPJ+2vSnMw= X-Received: by 2002:a17:906:1c46:: with SMTP id l6mr35297358ejg.304.1568306210522; Thu, 12 Sep 2019 09:36:50 -0700 (PDT) MIME-Version: 1.0 References: <2634903dafda431988ffabd873710768@lenovo.com> In-Reply-To: From: Oskar Senft Date: Thu, 12 Sep 2019 12:36:33 -0400 Message-ID: Subject: Re: phosphor-ipmi-flash: Update over eSPI interface To: Harry Sung1 Cc: Andrew MS1 Peng , "openbmc@lists.ozlabs.org" , Patrick Venture Content-Type: multipart/mixed; boundary="000000000000949b5405925dbe29" X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Sep 2019 16:37:03 -0000 --000000000000949b5405925dbe29 Content-Type: multipart/alternative; boundary="000000000000949b5305925dbe27" --000000000000949b5305925dbe27 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Here some more details on how the USB virtual NIC works: Sources - https://events.static.linuxfound.org/sites/events/files/slides/USB%20Gad= get%20Configfs%20API_0.pdf - https://developer.toradex.com/knowledge-base/usb-device-mode-(linux) Build Configuration linux/arch/arm/boot/dts/aspeed-bmc-[machine].dts +&vhub { + status =3D "okay"; +}; + gbmc/[...]/recipes-kernel/linux/linux-aspeed/[machine].cfg +# Enable virtual USB NIC +CONFIG_USB_CONFIGFS_ECM=3Dy +CONFIG_USB_CONFIGFS_ECM_SUBSET=3Dy BMC Runtime Configuration See attached usb_network.sh. This needs to be executed at startup. Obviously, you'll need to replace the vendor and product ID as well as the strings with something different. Network configuration needs to go into /etc/systemd/network. See attached 00-bmc-usb0.network. Host Runtime Configuration As soon as the BMC is booted, the host should see the BMC as an additional USB hub. The last command on the BMC will cause an actual USB device to be visible to the host. If it does not get auto-loaded, load the cdc_ether driver manually. Once loaded, this adds a "usb0" network interface on the host that can be configured like any other Ethernet device: ifconfig usb0 169.254.254.1 netmask 255.255.255.0 up >From here on you can then execute SSH / SCP from the host to the local BMC. However, for phosphor-ipmi-flash, it might be better to implement a new TCP-based method right in phosphor-ipmi-flash both on the BMC and the host side. The important bit is that whatever method you use, it must only stage the image to /tmp where phosphor-ipmi-flash-bios-verify.target can then pick it up for verification. You certainly don't want to have root-level access from the host to the BMC as that would allow the host to take ownership of the BMC. Oskar. On Wed, Sep 11, 2019 at 11:23 AM Oskar Senft wrote: > Hi Harry > > I've done some experiments with the USB virtual NIC on the AST2500 and > found that to work rather nicely. > > We're currently investigating in my team to use that interface as the > primary method for transferring data between the host and the BMC. From > what I can tell, this seems to be the fastest, most secure method. The > advantage also is that it doesn't need any low-level HW / memory access o= n > the host. However, the host still needs to have the USB NIC on its side > supported (driver) and configured (IP address). For our environment > (Linux), this is easy to achieve. > > It should be possible to update the phosphor-ipmi-flash BMC and host side > implementation to use a USB NIC for data transfer. However, we haven't > investigated those details yet. > > Other methods for data transfer (LPC, PCIe, eSPI, SuperI/O) all seem to > open up a large security hole in the AST2500. > > Oskar. > > On Wed, Sep 11, 2019 at 10:45 AM Patrick Venture > wrote: > >> On Wed, Sep 11, 2019 at 1:59 AM Harry Sung1 wrote: >> > >> > >> > > On Mon, Sep 9, 2019 at 7:01 AM Oskar Senft wrote: >> > > > >> > > > Hi Harry >> > > > >> > > > What's the behavior on eSPI? I assume you still have the >> aspeed-lpc-ctrl >> > > enabled, right? >> > > > >> > > > Thanks >> > > > Oskar. >> > >> > Hi Oskar, >> > Yes, I still enabled the aspeed-lpc-ctrl in my build. Because >> phosphor-ipmi-flash has some mandatory actions on /dev/aspeed-lpc-ctrl >> before flash (settings for HICR5, HICR7 and HICR8) even though these >> settings are meaningless for eSPI. >> > >> > Currently, I set ESPI084 (source address) and ESPI088 (target address) >> registers manually because linux seems not have a driver can help us to = set >> ESPI084 and ESPI088. >> > >> > Due to the limitation of AST2500, we can only write 256 bytes in one >> write operation (write shared memory). >> > Based on the test result, it takes about 30 mins to transfer a 32MB >> image over eSPI. >> >> :( wow, that's unfortunately rather slow. >> >> > >> > Thanks, >> > Harry >> > > > >> > > > On Mon, Sep 9, 2019 at 4:41 AM Harry Sung1 >> wrote: >> > > >> >> > > >> Hi Patrick, >> > > >> >> > > >> >> > > >> >> > > >> I found =E2=80=9Cphosphor-ipmi-flash=E2=80=9D have not support fl= ash over eSPI yet. >> > > >> >> > > >> May I ask if you have any plans to support flash over eSPI? >> > > >> >> > > >> >> > > >> >> > > >> I have done a simple test about shared memory between host and BM= C >> : >> > > >> >> > > >> The shared memory is work after I set ESPI084 (source address) an= d >> ESPI088 >> > > (target address) registers. >> > > >> >> > > >> But it has an limitation that only 256 bytes are available on eac= h >> page (4KB). >> > > >> >> > > >> >> > > >> For example, if host address starts to write from 0xFE0B0000 (BMC >> > > >> reserved enough memory already) >> > > >> >> > > >> Writable area are: >> > > >> >> > > >> 0xFE0B0000 ~ 0xFE0B00FF >> > > >> >> > > >> 0xFE0B1000 ~ 0xFE0B10FF >> > > >> >> > > >> 0xFE0B2000 ~ 0xFE0B20FF >> > > >> >> > > >> 0xFE0B3000 ~ 0xFE0B30FF >> > > >> >> > > >> =E2=80=A6 >> > > >> >> > > >> =E2=80=A6 >> > > >> >> > > >> =E2=80=A6 >> > > >> >> > > >> >> > > >> >> > > >> >> > > >> >> > > >> Thanks, >> > > >> Harry >> > > >> > > Harry, currently there's no plan to implement it as I have no method >> of testing >> > > it, However, it should prove fairly straightforward to add another >> option to >> > > the transport mechanism list. Please let me know if you run into an= y >> > > blockers. >> > >> > Hi Patrick, >> > Got it. The better way to set eSPI register is setting them by the >> driver, right? >> > For quick validation, I am going to use the " ipmilpc" interface and >> set necessary eSPI registers manually. >> >> I don't know as much about the eSPI variation of this. ipmilpc uses >> whatever LPC memory shared option is available (in coordination with >> the host+bmc). If eSPI doesn't use the aspeed-lpc-ctrl driver for >> what it needs, then perhaps a new option should be added ipmiespi? >> >> > >> > Thanks, >> > Harry >> > --000000000000949b5305925dbe27 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Here some more details on how the USB virtual NIC works:

Sources


Build Configuration

linux/arch/arm/boot/dts/aspeed-= bmc-[machine].dts

+&vhub {

+ =C2=A0 =C2=A0 =C2=A0 status =3D "= okay";

+};

+


gbmc/[...]/recipes-kernel/linux/linux-aspeed/[machine].cfg=

+# E= nable virtual USB NIC

+CONFIG_USB_CONFIGFS_ECM=3Dy

+CONFIG_USB_CONFIGF= S_ECM_SUBSET=3Dy


BMC Runtime Configuration

See attached=C2=A0us= b_network.sh. This needs to be executed at startup. Obviously, you'll n= eed to replace the vendor and product ID as well as the strings with someth= ing different.


Network configuration needs to go into /etc/systemd/network. See attached= =C2=A000-bmc-usb0.network.


Host Runtime Configuration

As soon as the BMC is booted, the host should see th= e BMC as an additional USB hub.


The last command on the BMC will cause an actual USB device to be visib= le to the host. If it does not get auto-loaded, load the cdc_ether driver m= anually. Once loaded, this adds a "usb0" network interface on the= host that can be configured like any other Ethernet device:

ifconfig usb= 0 169.254.254.1 netmask 255.255.255.0 up



From here on you can then ex= ecute SSH / SCP from the host to the local BMC. However, for=C2=A0phosphor-= ipmi-flash, it might be better to implement a new TCP-based method right in= phosphor-ipmi-flash both on the BMC and the host side. The important bit i= s that whatever method you use, it must only stage the image to /tmp where= =C2=A0phosphor-ipmi-flash-bios-verify.target can then pick it up for verifi= cation. You certainly don't want to have root-level access from the hos= t to the BMC as that would allow the host to take ownership of the BMC.

Oskar.

On Wed, Sep 11, 2019 at = 11:23 AM Oskar Senft <osk@google.com> wrote:
Hi Harry

I've done some experimen= ts with the USB virtual NIC on the AST2500 and found that to work rather ni= cely.

We're currently investigating in my team= to use that interface as the primary method for transferring data between = the host and the BMC. From what I can tell, this seems to be the=C2=A0faste= st, most secure method. The advantage also is that it doesn't need any = low-level HW / memory access on the host. However, the host still needs to = have the USB NIC on its side supported (driver) and configured (IP address)= . For our environment (Linux), this is easy to achieve.

It should be possible to update the phosphor-ipmi-flash BMC and host = side implementation to use a USB NIC for data transfer. However, we haven&#= 39;t investigated those details yet.

Other methods= for data transfer (LPC, PCIe, eSPI, SuperI/O) all seem to open up a large = security hole in the AST2500.

Oskar.

On Wed, Sep 11, 2019 at 10:45 AM Patrick Venture <venture@google.com> wrote:
<= /div>
On Wed, Sep 11, 2019= at 1:59 AM Harry Sung1 <hsung1@lenovo.com> wrote:
>
>
> > On Mon, Sep 9, 2019 at 7:01 AM Oskar Senft <osk@google.com> wrote:
> > >
> > > Hi Harry
> > >
> > > What's the behavior on eSPI? I assume you still have the= aspeed-lpc-ctrl
> > enabled, right?
> > >
> > > Thanks
> > > Oskar.
>
> Hi Oskar,
> Yes, I still enabled the aspeed-lpc-ctrl in my build. Because phosphor= -ipmi-flash has some mandatory actions on /dev/aspeed-lpc-ctrl before flash= (settings for HICR5, HICR7 and HICR8) even though these settings are meani= ngless for eSPI.
>
> Currently, I set ESPI084 (source address) and ESPI088 (target address)= registers manually because linux seems not have a driver can help us to se= t ESPI084 and ESPI088.
>
> Due to the limitation of AST2500, we can only write 256 bytes in one w= rite operation (write shared memory).
> Based on the test result, it takes about 30 mins to transfer a 32MB im= age over eSPI.

:( wow, that's unfortunately rather slow.

>
> Thanks,
> Harry
> > >
> > > On Mon, Sep 9, 2019 at 4:41 AM Harry Sung1 <hsung1@lenovo.com> wrote:<= br> > > >>
> > >> Hi Patrick,
> > >>
> > >>
> > >>
> > >> I found =E2=80=9Cphosphor-ipmi-flash=E2=80=9D have not s= upport flash over eSPI yet.
> > >>
> > >> May I ask if you have any plans to support flash over eS= PI?
> > >>
> > >>
> > >>
> > >> I have done a simple test about shared memory between ho= st and BMC :
> > >>
> > >> The shared memory is work after I set ESPI084 (source ad= dress) and ESPI088
> > (target address) registers.
> > >>
> > >> But it has an limitation that only 256 bytes are availab= le on each page (4KB).
> > >>
> > >>
> > >> For example, if host address starts to write from 0xFE0B= 0000 (BMC
> > >> reserved enough memory already)
> > >>
> > >> Writable area are:
> > >>
> > >> 0xFE0B0000 ~ 0xFE0B00FF
> > >>
> > >> 0xFE0B1000 ~ 0xFE0B10FF
> > >>
> > >> 0xFE0B2000 ~ 0xFE0B20FF
> > >>
> > >> 0xFE0B3000 ~ 0xFE0B30FF
> > >>
> > >> =E2=80=A6
> > >>
> > >> =E2=80=A6
> > >>
> > >> =E2=80=A6
> > >>
> > >>
> > >>
> > >>
> > >>
> > >> Thanks,
> > >> Harry
> >
> > Harry, currently there's no plan to implement it as I have no= method of testing
> > it,=C2=A0 However, it should prove fairly straightforward to add = another option to
> > the transport mechanism list.=C2=A0 Please let me know if you run= into any
> > blockers.
>
> Hi Patrick,
> Got it. The better way to set eSPI register is setting them by the dri= ver, right?
> For quick validation, I am going to use the " ipmilpc" inter= face and set necessary eSPI registers manually.

I don't know as much about the eSPI variation of this.=C2=A0 ipmilpc us= es
whatever LPC memory shared option is available (in coordination with
the host+bmc).=C2=A0 If eSPI doesn't use the aspeed-lpc-ctrl driver for=
what it needs, then perhaps a new option should be added ipmiespi?

>
> Thanks,
> Harry
--000000000000949b5305925dbe27-- --000000000000949b5405925dbe29 Content-Type: application/octet-stream; name="00-bmc-usb0.network" Content-Disposition: attachment; filename="00-bmc-usb0.network" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_k0gx0e800 W01hdGNoXQpOYW1lPXVzYjAKW0FkZHJlc3NdCkFkZHJlc3M9MTY5LjI1NC4yNTQuMjU0LzI0CltO ZXR3b3JrXQpMaW5rTG9jYWxBZGRyZXNzaW5nPWlwdjYKSVB2NkFjY2VwdFJBPW5vCg== --000000000000949b5405925dbe29 Content-Type: application/x-shellscript; name="usb_network.sh" Content-Disposition: attachment; filename="usb_network.sh" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_k0gx0e8c1 IyEvYmluL2Jhc2gKCiMgQWRhcHRlZCBmcm9tIHVwc3RyZWFtIHNjcmlwdDoKIyBodHRwczovL2dp dGh1Yi5jb20vb3BlbmJtYy9tZXRhLXF1YW50YS9ibG9iLzQxZmY1NDYwNWE4ZGY2ZTQ1NmUyMDM1 YjQxMDExNDU0NWJjOTQyODQvbWV0YS1nc2ovcmVjaXBlcy1waG9zcGhvci91c2ItbmV0d29yay9m aWxlcy91c2JfbmV0d29yay5zaAoKZnVuY3Rpb24gc3RhcnQoKSB7CiAgaWYgW1sgISAtZCBnMSBd XTsgdGhlbgogICAgbWtkaXIgZzEKICBmaQoKICBjZCBnMQoKICAjIFRPRE86IFVwZGF0ZSBWSUQg YW5kIFBJRAogIGVjaG8gMHgxMjA5ID4gaWRWZW5kb3IKICBlY2hvIDB4MTIzNCA+IGlkUHJvZHVj dAoKICBpZiBbWyAhIC1kIHN0cmluZ3MvMHg0MDkgXV07IHRoZW4KICAgIG1rZGlyIC1wIHN0cmlu Z3MvMHg0MDkK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