Re: [OpenWrt-Devel] Booting D-Link DNS-313, kernel requirements for OpenWRT?

2018-01-17 Thread Hans Ulli Kroll
Hi Linus

On Tue, 16 Jan 2018, Linus Walleij wrote:

> Hi folks,
> 
> I managed to boot a v4.16-ish kernel and OpenWRT rootfs
> on the D-Link DNS-313
> (reference https://dflund.se/~triad/krad/dlink-dns-313/)

interesting device, especially for the VBUS "solution", so I decided to 
buy for testing.
I assume VBUS is only connected to GPIO.

> I used the raidsonic rootfs built from scratch (the prebuilt
> images on the site seem broken, just contains zeroes).
>

OpenWRT is currently in (re)merging status from LEDE
maybe LEDE images can work.
I've done a testbuild with current LEDE and ext4 target which fails,
make be a
make -j1 V=s 
or a testbuild for my ALIX6F2 give me some light here.

> Booting Linux on physical CPU 0x0
> Linux version 4.15.0-rc7+ (linus@fabina) (gcc version 5.3.1 20160113
> (Linaro GCC 5.3-2016.02)) #39 PREEMPT Tue Jan 16 23:09:18 CET 2018
> CPU: FA526 [66015261] revision 1 (ARMv4), cr=397f
> CPU: VIVT data cache, VIVT instruction cache
> OF: fdt: Machine model: D-Link DNS-313 1-Bay Network Storage Enclosure
> Memory policy: Data cache writeback
> ()
> ata1.00: ATA-6: ST3160023AS, 3.05, max UDMA/133
> ata1.00: 312581808 sectors, multi 0: LBA48
> ata1.00: configured for UDMA/133
> scsi 0:0:0:0: Direct-Access ATA  ST3160023AS  3.05 PQ: 0 ANSI: 5
> sd 0:0:0:0: [sda] 312581808 512-byte logical blocks: (160 GB/149 GiB)
> sd 0:0:0:0: [sda] Write Protect is off
> sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't
> support DPO or FUA
>  sda: sda1 sda2 sda3 sda4
> sd 0:0:0:0: [sda] Attached SCSI disk
> EXT4-fs (sda4): couldn't mount as ext3 due to feature incompatibilities
> EXT4-fs (sda4): couldn't mount as ext2 due to feature incompatibilities
> EXT4-fs (sda4): mounted filesystem with ordered data mode. Opts: (null)
> VFS: Mounted root (ext4 filesystem) readonly on device 8:4.

read only ?
I think this must be read write, must verify this with my ALIX6F2 running 
openWRT on a CF card with ext4 as rootfs.

Greetings
Hans Ulli Kroll
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 3/5] tools: add iucode-tool

2018-01-17 Thread Zoltan HERPAI
Add tool to "compile" Intel microcode files. The tool will be
compiled for host (to split the microcode.dat) and for target
(to forcibly reload the microcode or scan the system if required).

Signed-off-by: Zoltan HERPAI 
---
 package/system/iucode-tool/Makefile | 47 +
 1 file changed, 47 insertions(+)
 create mode 100644 package/system/iucode-tool/Makefile

diff --git a/package/system/iucode-tool/Makefile 
b/package/system/iucode-tool/Makefile
new file mode 100644
index 000..4381a3a
--- /dev/null
+++ b/package/system/iucode-tool/Makefile
@@ -0,0 +1,47 @@
+#
+# Copyright (C) 2018 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=iucode-tool
+PKG_VERSION:=2.2
+PKG_RELEASE:=1
+
+PKG_SOURCE:=iucode-tool_$(PKG_VERSION).tar.xz
+PKG_SOURCE_URL:=https://gitlab.com/iucode-tool/releases/raw/latest
+PKG_HASH:=9810daf925b8a9ca244adc4e1916bcab65601c9ebe87e91c2281f78055982971
+
+PKG_BUILD_DEPENDS:=USE_UCLIBC:argp-standalone USE_MUSL:argp-standalone
+
+PKG_MAINTAINER:=Zoltan HERPAI 
+PKG_LICENSE:=GPL-2.0
+
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/host-build.mk
+
+define Package/iucode-tool
+  SECTION:=utils
+  CATEGORY:=Base system
+  URL:=$(PKG_SOURCE_URL)
+  DEPENDS:=@TARGET_x86
+  TITLE:=Intel microcode loader
+endef
+
+define Package/iucode-tool/install
+   $(INSTALL_DIR) $(1)/lib/firmware
+   $(INSTALL_DIR) $(1)/usr/bin
+   $(INSTALL_BIN) $(PKG_BUILD_DIR)/iucode_tool $(1)/usr/bin/
+endef
+
+define Host/Install
+   $(INSTALL_BIN) $(HOST_BUILD_DIR)/iucode_tool 
$(STAGING_DIR_HOST)/bin/iucode_tool
+endef
+
+$(eval $(call HostBuild))
+$(eval $(call BuildPackage,iucode-tool))
-- 
1.9.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 1/5] x86: enable microcode loading for Intel and AMD

2018-01-17 Thread Zoltan HERPAI
Enable for 4.9 and 4.14.

Signed-off-by: Zoltan HERPAI 
---
 target/linux/x86/config-4.14 | 5 -
 target/linux/x86/config-4.9  | 5 -
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/target/linux/x86/config-4.14 b/target/linux/x86/config-4.14
index b88fa77..9ea0d90 100644
--- a/target/linux/x86/config-4.14
+++ b/target/linux/x86/config-4.14
@@ -313,7 +313,10 @@ CONFIG_M586MMX=y
 # CONFIG_MFD_INTEL_LPSS_PCI is not set
 # CONFIG_MGEODEGX1 is not set
 # CONFIG_MGEODE_LX is not set
-# CONFIG_MICROCODE is not set
+CONFIG_MICROCODE=y
+CONFIG_MICROCODE_AMD=y
+CONFIG_MICROCODE_INTEL=y
+CONFIG_MICROCODE_OLD_INTERFACE=y
 # CONFIG_MK6 is not set
 # CONFIG_MK7 is not set
 # CONFIG_MK8 is not set
diff --git a/target/linux/x86/config-4.9 b/target/linux/x86/config-4.9
index b500354..554e696 100644
--- a/target/linux/x86/config-4.9
+++ b/target/linux/x86/config-4.9
@@ -290,7 +290,10 @@ CONFIG_M586MMX=y
 # CONFIG_MFD_INTEL_LPSS_PCI is not set
 # CONFIG_MGEODEGX1 is not set
 # CONFIG_MGEODE_LX is not set
-# CONFIG_MICROCODE is not set
+CONFIG_MICROCODE=y
+CONFIG_MICROCODE_AMD=y
+CONFIG_MICROCODE_INTEL=y
+CONFIG_MICROCODE_OLD_INTERFACE=y
 # CONFIG_MK6 is not set
 # CONFIG_MK7 is not set
 # CONFIG_MK8 is not set
-- 
1.9.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 4/5] firmware: add microcode package for Intel

2018-01-17 Thread Zoltan HERPAI
Compiling the Intel microcode package results in a
microcode.bin and a microcode-64.bin. As we can
decide based on the subtarget which should be used,
we'll only split the required .bin file with
iucode-tool.

Instead of using the large microcode.bin/microcode-64.bin, the
splitted ucode files (separate for CPU families) will be
installed.
 
The microcodes are updated from preinit - that's the
earliest place where we can do it.

Signed-off-by: Zoltan HERPAI 
---
 package/firmware/intel-microcode/Makefile  | 51 ++
 .../intel-microcode/files/intel-microcode.preinit  |  8 
 2 files changed, 59 insertions(+)
 create mode 100644 package/firmware/intel-microcode/Makefile
 create mode 100644 
package/firmware/intel-microcode/files/intel-microcode.preinit

diff --git a/package/firmware/intel-microcode/Makefile 
b/package/firmware/intel-microcode/Makefile
new file mode 100644
index 000..0af900c
--- /dev/null
+++ b/package/firmware/intel-microcode/Makefile
@@ -0,0 +1,51 @@
+#
+# Copyright (C) 2018 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=intel-microcode
+PKG_VERSION:=20171215
+PKG_RELEASE:=1
+
+PKG_SOURCE:=intel-microcode_3.$(PKG_VERSION).$(PKG_RELEASE).tar.xz
+PKG_SOURCE_URL:=http://ftp.debian.org/debian/pool/non-free/i/intel-microcode/
+PKG_HASH:=eca8efc0a6dc456a8723204477e229577c1079fa5c1a10b6ba95d11e261ffa4d
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-3.$(PKG_VERSION).$(PKG_RELEASE)
+
+PKG_BUILD_DEPENDS:=iucode-tool/host
+
+ifdef CONFIG_TARGET_x86_64
+   MICROCODE:="intel-microcode-64"
+else
+   MICROCODE:="intel-microcode"
+endif
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/intel-microcode
+  SECTION:=firmware
+  CATEGORY:=Firmware
+  URL:=$(PKG_SOURCE_URL)
+  DEPENDS:=@TARGET_x86 +iucode-tool
+  TITLE:=Intel x86 CPU microcode
+endef
+
+define Build/Compile
+   IUCODE_TOOL=$(STAGING_DIR)/../host/bin/iucode_tool $(MAKE) -C 
$(PKG_BUILD_DIR)
+   mkdir $(PKG_BUILD_DIR)/intel-ucode
+   $(STAGING_DIR)/../host/bin/iucode_tool -q \
+   --write-firmware=$(PKG_BUILD_DIR)/intel-ucode 
$(PKG_BUILD_DIR)/$(MICROCODE).bin
+endef
+
+define Package/intel-microcode/install
+   $(INSTALL_DIR) $(1)/lib/firmware/intel-ucode
+   $(INSTALL_DATA) $(PKG_BUILD_DIR)/intel-ucode/* 
$(1)/lib/firmware/intel-ucode
+   $(INSTALL_DIR) $(1)/lib/preinit
+   $(INSTALL_BIN) ./files/intel-microcode.preinit 
$(1)/lib/preinit/02_load_intel_ucode
+endef
+
+$(eval $(call BuildPackage,intel-microcode))
diff --git a/package/firmware/intel-microcode/files/intel-microcode.preinit 
b/package/firmware/intel-microcode/files/intel-microcode.preinit
new file mode 100644
index 000..7f9279c
--- /dev/null
+++ b/package/firmware/intel-microcode/files/intel-microcode.preinit
@@ -0,0 +1,8 @@
+#!/bin/sh
+# Copyright (C) 2018 OpenWrt.org
+
+do_load_intel_ucode() {
+   echo 1 > /sys/devices/system/cpu/microcode/reload
+}
+
+boot_hook_add preinit_main do_load_intel_ucode
-- 
1.9.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 0/5] x86: add support for microcode update

2018-01-17 Thread Zoltan HERPAI
Hi,

This series will add support for microcode update on x86 targets,
in light of the recent security issues.

While other distributions use an early initramfs approach to update 
the microcode as early as possible, in OpenWrt the earliest place
where we can do this is preinit.

The Intel microcode package is using the source package by Debian,
the AMD microcode package is downloaded from the linux-firmware 
git repository.

This was tested on various Intel-based desktops with ancient BIOSes.

Once the series is merged into trunk, this could/should be backported
into 17.01 and 15.05 without too much hassle.

Thanks,
Zoltan H


Zoltan HERPAI (5):
  x86: enable microcode loading for Intel and AMD
  firmware: add microcode package for AMD64
  tools: add iucode-tool
  firmware: add microcode package for Intel
  packages: intel-microcode: update to 20180108

 package/firmware/intel-microcode/Makefile  | 51 ++
 .../intel-microcode/files/intel-microcode.preinit  |  8 
 package/firmware/linux-firmware/x86.mk |  9 
 package/system/iucode-tool/Makefile| 47 
 target/linux/x86/config-4.14   |  5 ++-
 target/linux/x86/config-4.9|  5 ++-
 6 files changed, 123 insertions(+), 2 deletions(-)
 create mode 100644 package/firmware/intel-microcode/Makefile
 create mode 100644 
package/firmware/intel-microcode/files/intel-microcode.preinit
 create mode 100644 package/firmware/linux-firmware/x86.mk
 create mode 100644 package/system/iucode-tool/Makefile

-- 
1.9.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 5/5] packages: intel-microcode: update to 20180108

2018-01-17 Thread Zoltan HERPAI
 - update microcodes for various CPUs
 - Implements IBRS/IBPB support and enhances LFENCE: mitigation
   against Spectre (CVE-2017-5715)
 - downgrade microcodes for two platforms, due to reasons unknown
   from Intel

Signed-off-by: Zoltan HERPAI 
---
 package/firmware/intel-microcode/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/package/firmware/intel-microcode/Makefile 
b/package/firmware/intel-microcode/Makefile
index 0af900c..962454e 100644
--- a/package/firmware/intel-microcode/Makefile
+++ b/package/firmware/intel-microcode/Makefile
@@ -8,12 +8,12 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=intel-microcode
-PKG_VERSION:=20171215
+PKG_VERSION:=20180108
 PKG_RELEASE:=1
 
 PKG_SOURCE:=intel-microcode_3.$(PKG_VERSION).$(PKG_RELEASE).tar.xz
 PKG_SOURCE_URL:=http://ftp.debian.org/debian/pool/non-free/i/intel-microcode/
-PKG_HASH:=eca8efc0a6dc456a8723204477e229577c1079fa5c1a10b6ba95d11e261ffa4d
+PKG_HASH:=7a1a8bbbc6520be14e99fab40581c471861e8d731593447dfc9e9bd6b630712d
 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-3.$(PKG_VERSION).$(PKG_RELEASE)
 
 PKG_BUILD_DEPENDS:=iucode-tool/host
-- 
1.9.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 2/5] firmware: add microcode package for AMD64

2018-01-17 Thread Zoltan HERPAI
Signed-off-by: Zoltan HERPAI 
---
 package/firmware/linux-firmware/x86.mk | 9 +
 1 file changed, 9 insertions(+)
 create mode 100644 package/firmware/linux-firmware/x86.mk

diff --git a/package/firmware/linux-firmware/x86.mk 
b/package/firmware/linux-firmware/x86.mk
new file mode 100644
index 000..2dfe7b0
--- /dev/null
+++ b/package/firmware/linux-firmware/x86.mk
@@ -0,0 +1,9 @@
+Package/amd64-microcode = $(call Package/firmware-default,AMD64 CPU microcode)
+define Package/amd64-microcode/install
+   $(INSTALL_DIR) $(1)/lib/firmware/amd-ucode
+   $(INSTALL_DATA) $(PKG_BUILD_DIR)/amd-ucode/microcode_amd.bin 
$(1)/lib/firmware/amd-ucode
+   $(INSTALL_DATA) $(PKG_BUILD_DIR)/amd-ucode/microcode_amd_fam15h.bin 
$(1)/lib/firmware/amd-ucode
+   $(INSTALL_DATA) $(PKG_BUILD_DIR)/amd-ucode/microcode_amd_fam16h.bin 
$(1)/lib/firmware/amd-ucode
+endef
+$(eval $(call BuildPackage,amd64-microcode))
+
-- 
1.9.1
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH 0/5] x86: add support for microcode update

2018-01-17 Thread Florian Fainelli
On January 17, 2018 11:41:01 AM PST, Zoltan HERPAI  wrote:
>Hi,
>
>This series will add support for microcode update on x86 targets,
>in light of the recent security issues.
>
>While other distributions use an early initramfs approach to update 
>the microcode as early as possible, in OpenWrt the earliest place
>where we can do this is preinit.
>
>The Intel microcode package is using the source package by Debian,
>the AMD microcode package is downloaded from the linux-firmware 
>git repository.
>
>This was tested on various Intel-based desktops with ancient BIOSes.
>
>Once the series is merged into trunk, this could/should be backported
>into 17.01 and 15.05 without too much hassle.

FWIW:

Reviewed-by: Florian Fainelli 

-- 
Florian
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH 3/5] tools: add iucode-tool

2018-01-17 Thread Syrone Wong
There is another intel ucode generator in Archlinux repo, it seems the
code is more elegant and don't require additional dependency. Do you
have any idea?

https://git.archlinux.org/svntogit/packages.git/tree/trunk?h=packages/intel-ucode


Best Regards,
Syrone Wong


On Thu, Jan 18, 2018 at 3:41 AM, Zoltan HERPAI  wrote:
> Add tool to "compile" Intel microcode files. The tool will be
> compiled for host (to split the microcode.dat) and for target
> (to forcibly reload the microcode or scan the system if required).
>
> Signed-off-by: Zoltan HERPAI 
> ---
>  package/system/iucode-tool/Makefile | 47 
> +
>  1 file changed, 47 insertions(+)
>  create mode 100644 package/system/iucode-tool/Makefile
>
> diff --git a/package/system/iucode-tool/Makefile 
> b/package/system/iucode-tool/Makefile
> new file mode 100644
> index 000..4381a3a
> --- /dev/null
> +++ b/package/system/iucode-tool/Makefile
> @@ -0,0 +1,47 @@
> +#
> +# Copyright (C) 2018 OpenWrt.org
> +#
> +# This is free software, licensed under the GNU General Public License v2.
> +# See /LICENSE for more information.
> +#
> +
> +include $(TOPDIR)/rules.mk
> +
> +PKG_NAME:=iucode-tool
> +PKG_VERSION:=2.2
> +PKG_RELEASE:=1
> +
> +PKG_SOURCE:=iucode-tool_$(PKG_VERSION).tar.xz
> +PKG_SOURCE_URL:=https://gitlab.com/iucode-tool/releases/raw/latest
> +PKG_HASH:=9810daf925b8a9ca244adc4e1916bcab65601c9ebe87e91c2281f78055982971
> +
> +PKG_BUILD_DEPENDS:=USE_UCLIBC:argp-standalone USE_MUSL:argp-standalone
> +
> +PKG_MAINTAINER:=Zoltan HERPAI 
> +PKG_LICENSE:=GPL-2.0
> +
> +PKG_INSTALL:=1
> +
> +include $(INCLUDE_DIR)/package.mk
> +include $(INCLUDE_DIR)/host-build.mk
> +
> +define Package/iucode-tool
> +  SECTION:=utils
> +  CATEGORY:=Base system
> +  URL:=$(PKG_SOURCE_URL)
> +  DEPENDS:=@TARGET_x86
> +  TITLE:=Intel microcode loader
> +endef
> +
> +define Package/iucode-tool/install
> +   $(INSTALL_DIR) $(1)/lib/firmware
> +   $(INSTALL_DIR) $(1)/usr/bin
> +   $(INSTALL_BIN) $(PKG_BUILD_DIR)/iucode_tool $(1)/usr/bin/
> +endef
> +
> +define Host/Install
> +   $(INSTALL_BIN) $(HOST_BUILD_DIR)/iucode_tool 
> $(STAGING_DIR_HOST)/bin/iucode_tool
> +endef
> +
> +$(eval $(call HostBuild))
> +$(eval $(call BuildPackage,iucode-tool))
> --
> 1.9.1
> ___
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel