diff mbox

[v2,6/8] tools rpmb: add RPBM access tool

Message ID 1459768284-26997-7-git-send-email-tomas.winkler@intel.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Winkler, Tomas April 4, 2016, 11:11 a.m. UTC
Add simple RPMB host testing tool. It can be used
to program key, write and read data block, and retrieve
write counter.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
V2: resend
 MAINTAINERS           |   1 +
 tools/Makefile        |  16 +-
 tools/rpmb/.gitignore |   2 +
 tools/rpmb/Makefile   |  32 ++
 tools/rpmb/rpmb.c     | 807 ++++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 853 insertions(+), 5 deletions(-)
 create mode 100644 tools/rpmb/.gitignore
 create mode 100644 tools/rpmb/Makefile
 create mode 100644 tools/rpmb/rpmb.c

Comments

kernel test robot April 5, 2016, 12:16 p.m. UTC | #1
Hi Tomas,

[auto build test ERROR on char-misc/char-misc-testing]
[also build test ERROR on v4.6-rc2 next-20160405]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/Tomas-Winkler/Replay-Protected-Memory-Block-RPMB-subsystem/20160404-192243
config: x86_64-randconfig-s3-04051858 (attached as .config)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

   make[3]: *** No rule to make target 'kernel/gcov/base.o', needed by 'kernel/gcov/built-in.o'.
   make[3]: *** No rule to make target 'kernel/gcov/fs.o', needed by 'kernel/gcov/built-in.o'.
>> make[3]: *** No rule to make target 'kernel/gcov/gcc_3_4.o', needed by 'kernel/gcov/built-in.o'.
   make[3]: Target '__build' not remade because of errors.
--
>> make[3]: *** No rule to make target 'tools/objtool/objtool', needed by 'drivers/mfd/88pm800.o'.
   make[3]: Target '__build' not remade because of errors.
--
>> make[4]: *** No rule to make target 'tools/objtool/objtool', needed by 'drivers/firmware/google/memconsole.o'.
   make[4]: Target '__build' not remade because of errors.
--
>> make[4]: *** No rule to make target 'tools/objtool/objtool', needed by 'drivers/iio/dac/ad5624r_spi.o'.
   make[4]: Target '__build' not remade because of errors.
--
>> make[4]: *** No rule to make target 'tools/objtool/objtool', needed by 'drivers/iio/trigger/iio-trig-interrupt.o'.
   make[4]: Target '__build' not remade because of errors.
--
>> make[4]: *** No rule to make target 'tools/objtool/objtool', needed by 'drivers/input/joystick/gf2k.o'.
   make[4]: *** [drivers/input/joystick/iforce] Error 2
   make[4]: Target '__build' not remade because of errors.
--
>> make[4]: *** No rule to make target 'tools/objtool/objtool', needed by 'drivers/misc/eeprom/max6875.o'.
   make[4]: Target '__build' not remade because of errors.
--
>> make[4]: *** No rule to make target 'tools/objtool/objtool', needed by 'drivers/mmc/card/mmc_test.o'.
   make[4]: Target '__build' not remade because of errors.
--
>> make[4]: *** No rule to make target 'tools/objtool/objtool', needed by 'drivers/mmc/host/sdhci.o'.
   make[4]: Target '__build' not remade because of errors.
--
>> make[4]: *** No rule to make target 'tools/objtool/objtool', needed by 'drivers/pinctrl/intel/pinctrl-intel.o'.
   make[4]: Target '__build' not remade because of errors.
--
>> make[4]: *** No rule to make target 'tools/objtool/objtool', needed by 'drivers/platform/chrome/chromeos_laptop.o'.
   make[4]: Target '__build' not remade because of errors.
..

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
kernel test robot April 5, 2016, 12:29 p.m. UTC | #2
Hi Tomas,

[auto build test ERROR on char-misc/char-misc-testing]
[also build test ERROR on v4.6-rc2 next-20160405]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/Tomas-Winkler/Replay-Protected-Memory-Block-RPMB-subsystem/20160404-192243
config: x86_64-randconfig-s5-04051858 (attached as .config)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

   make[3]: *** No rule to make target 'arch/x86/kernel/process_64.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/signal.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/signal_compat.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/traps.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/irq.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/irq_64.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/dumpstack_64.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/time.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/ioport.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/dumpstack.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/nmi.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/setup.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/x86_init.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/i8259.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/irqinit.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/jump_label.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/irq_work.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/probe_roms.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/sys_x86_64.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/x8664_ksyms_64.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/mcount_64.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/ksysfs.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/bootflag.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/e820.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/pci-dma.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/quirks.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/topology.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/kdebugfs.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/alternative.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/i8253.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/pci-nommu.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/hw_breakpoint.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/tsc.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/tsc_msr.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/io_delay.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/rtc.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/pci-iommu_table.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/resource.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/process.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/ptrace.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/tls.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/step.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/stacktrace.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/reboot.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/msr.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/cpuid.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/early-quirks.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/smp.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/smpboot.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/tsc_sync.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/setup_percpu.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/mpparse.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/ftrace.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/trace_clock.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/machine_kexec_64.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/relocate_kernel_64.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/crash.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/kexec-bzimage64.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/doublefault.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/hpet.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/amd_nb.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/test_rodata.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/nmi_selftest.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/kvm.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/kvmclock.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/paravirt.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/paravirt_patch_64.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/pvclock.o', needed by 'arch/x86/kernel/built-in.o'.
>> make[3]: *** No rule to make target 'arch/x86/kernel/pmem.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/pcspeaker.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/pci-swiotlb.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/uprobes.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/sysfb.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/sysfb_simplefb.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/perf_regs.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/tracepoint.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/vsmp_64.o', needed by 'arch/x86/kernel/built-in.o'.
   make[3]: *** No rule to make target 'arch/x86/kernel/head_64.o', needed by '__build'.
   make[3]: *** No rule to make target 'arch/x86/kernel/head64.o', needed by '__build'.
   make[3]: *** No rule to make target 'arch/x86/kernel/head.o', needed by '__build'.
   make[3]: *** [arch/x86/kernel/acpi] Error 2
   make[3]: *** [arch/x86/kernel/fpu] Error 2
   make[3]: *** [arch/x86/kernel/apic] Error 2
   make[3]: *** [arch/x86/kernel/cpu] Error 2
   make[3]: Target '__build' not remade because of errors.
--
   make[3]: *** No rule to make target 'fs/squashfs/block.o', needed by 'fs/squashfs/squashfs.o'.
   make[3]: *** No rule to make target 'fs/squashfs/cache.o', needed by 'fs/squashfs/squashfs.o'.
   make[3]: *** No rule to make target 'fs/squashfs/dir.o', needed by 'fs/squashfs/squashfs.o'.
   make[3]: *** No rule to make target 'fs/squashfs/export.o', needed by 'fs/squashfs/squashfs.o'.
   make[3]: *** No rule to make target 'fs/squashfs/file.o', needed by 'fs/squashfs/squashfs.o'.
   make[3]: *** No rule to make target 'fs/squashfs/fragment.o', needed by 'fs/squashfs/squashfs.o'.
   make[3]: *** No rule to make target 'fs/squashfs/id.o', needed by 'fs/squashfs/squashfs.o'.
   make[3]: *** No rule to make target 'fs/squashfs/inode.o', needed by 'fs/squashfs/squashfs.o'.
   make[3]: *** No rule to make target 'fs/squashfs/namei.o', needed by 'fs/squashfs/squashfs.o'.
   make[3]: *** No rule to make target 'fs/squashfs/super.o', needed by 'fs/squashfs/squashfs.o'.
   make[3]: *** No rule to make target 'fs/squashfs/symlink.o', needed by 'fs/squashfs/squashfs.o'.
   make[3]: *** No rule to make target 'fs/squashfs/decompressor.o', needed by 'fs/squashfs/squashfs.o'.
>> make[3]: *** No rule to make target 'fs/squashfs/file_direct.o', needed by 'fs/squashfs/squashfs.o'.
>> make[3]: *** No rule to make target 'fs/squashfs/page_actor.o', needed by 'fs/squashfs/squashfs.o'.
   make[3]: *** No rule to make target 'fs/squashfs/decompressor_single.o', needed by 'fs/squashfs/squashfs.o'.
   make[3]: *** No rule to make target 'fs/squashfs/xattr.o', needed by 'fs/squashfs/squashfs.o'.
   make[3]: *** No rule to make target 'fs/squashfs/xattr_id.o', needed by 'fs/squashfs/squashfs.o'.
   make[3]: *** No rule to make target 'fs/squashfs/lzo_wrapper.o', needed by 'fs/squashfs/squashfs.o'.
   make[3]: *** No rule to make target 'fs/squashfs/xz_wrapper.o', needed by 'fs/squashfs/squashfs.o'.
   make[3]: Target '__build' not remade because of errors.
--
   make[3]: *** No rule to make target 'drivers/scsi/scsi.o', needed by 'drivers/scsi/scsi_mod.o'.
   make[3]: *** No rule to make target 'drivers/scsi/hosts.o', needed by 'drivers/scsi/scsi_mod.o'.
   make[3]: *** No rule to make target 'drivers/scsi/scsi_ioctl.o', needed by 'drivers/scsi/scsi_mod.o'.
   make[3]: *** No rule to make target 'drivers/scsi/scsicam.o', needed by 'drivers/scsi/scsi_mod.o'.
   make[3]: *** No rule to make target 'drivers/scsi/scsi_error.o', needed by 'drivers/scsi/scsi_mod.o'.
   make[3]: *** No rule to make target 'drivers/scsi/scsi_lib.o', needed by 'drivers/scsi/scsi_mod.o'.
   make[3]: *** No rule to make target 'drivers/scsi/scsi_common.o', needed by 'drivers/scsi/scsi_mod.o'.
   make[3]: *** No rule to make target 'drivers/scsi/scsi_lib_dma.o', needed by 'drivers/scsi/scsi_mod.o'.
   make[3]: *** No rule to make target 'drivers/scsi/scsi_scan.o', needed by 'drivers/scsi/scsi_mod.o'.
   make[3]: *** No rule to make target 'drivers/scsi/scsi_sysfs.o', needed by 'drivers/scsi/scsi_mod.o'.
   make[3]: *** No rule to make target 'drivers/scsi/scsi_devinfo.o', needed by 'drivers/scsi/scsi_mod.o'.
   make[3]: *** No rule to make target 'drivers/scsi/scsi_sysctl.o', needed by 'drivers/scsi/scsi_mod.o'.
   make[3]: *** No rule to make target 'drivers/scsi/scsi_proc.o', needed by 'drivers/scsi/scsi_mod.o'.
   make[3]: *** No rule to make target 'drivers/scsi/scsi_trace.o', needed by 'drivers/scsi/scsi_mod.o'.
   make[3]: *** No rule to make target 'drivers/scsi/scsi_logging.o', needed by 'drivers/scsi/scsi_mod.o'.
   make[3]: *** No rule to make target 'drivers/scsi/scsi_pm.o', needed by 'drivers/scsi/scsi_mod.o'.
   make[3]: *** No rule to make target 'drivers/scsi/raid_class.o', needed by 'drivers/scsi/built-in.o'.
   make[3]: *** No rule to make target 'drivers/scsi/scsi_transport_spi.o', needed by 'drivers/scsi/built-in.o'.
   make[3]: *** No rule to make target 'drivers/scsi/scsi_transport_sas.o', needed by 'drivers/scsi/built-in.o'.
   make[3]: *** No rule to make target 'drivers/scsi/scsi_transport_srp.o', needed by 'drivers/scsi/built-in.o'.
   make[3]: *** No rule to make target 'drivers/scsi/iscsi_boot_sysfs.o', needed by 'drivers/scsi/built-in.o'.
>> make[3]: *** No rule to make target 'drivers/scsi/dpt_i2o.o', needed by 'drivers/scsi/built-in.o'.
>> make[3]: *** No rule to make target 'drivers/scsi/ips.o', needed by 'drivers/scsi/built-in.o'.
>> make[3]: *** No rule to make target 'drivers/scsi/fdomain.o', needed by 'drivers/scsi/built-in.o'.
>> make[3]: *** No rule to make target 'drivers/scsi/dmx3191d.o', needed by 'drivers/scsi/built-in.o'.
>> make[3]: *** No rule to make target 'drivers/scsi/hpsa.o', needed by 'drivers/scsi/built-in.o'.
>> make[3]: *** No rule to make target 'drivers/scsi/dc395x.o', needed by 'drivers/scsi/built-in.o'.
>> make[3]: *** No rule to make target 'drivers/scsi/esp_scsi.o', needed by 'drivers/scsi/built-in.o'.
>> make[3]: *** No rule to make target 'drivers/scsi/am53c974.o', needed by 'drivers/scsi/built-in.o'.
>> make[3]: *** No rule to make target 'drivers/scsi/megaraid.o', needed by 'drivers/scsi/built-in.o'.
>> make[3]: *** No rule to make target 'drivers/scsi/a100u2w.o', needed by 'drivers/scsi/built-in.o'.
>> make[3]: *** No rule to make target 'drivers/scsi/3w-xxxx.o', needed by 'drivers/scsi/built-in.o'.
>> make[3]: *** No rule to make target 'drivers/scsi/3w-9xxx.o', needed by 'drivers/scsi/built-in.o'.
>> make[3]: *** No rule to make target 'drivers/scsi/ppa.o', needed by 'drivers/scsi/built-in.o'.
>> make[3]: *** No rule to make target 'drivers/scsi/stex.o', needed by 'drivers/scsi/built-in.o'.
   make[3]: *** No rule to make target 'drivers/scsi/virtio_scsi.o', needed by 'drivers/scsi/built-in.o'.
>> make[3]: *** No rule to make target 'drivers/scsi/vmw_pvscsi.o', needed by 'drivers/scsi/built-in.o'.
   make[3]: *** No rule to make target 'drivers/scsi/st.o', needed by 'drivers/scsi/built-in.o'.
   make[3]: *** No rule to make target 'drivers/scsi/sd.o', needed by 'drivers/scsi/sd_mod.o'.
   make[3]: *** No rule to make target 'drivers/scsi/sd_dif.o', needed by 'drivers/scsi/sd_mod.o'.
>> make[3]: *** No rule to make target 'drivers/scsi/sr.o', needed by 'drivers/scsi/sr_mod.o'.
>> make[3]: *** No rule to make target 'drivers/scsi/sr_ioctl.o', needed by 'drivers/scsi/sr_mod.o'.
>> make[3]: *** No rule to make target 'drivers/scsi/sr_vendor.o', needed by 'drivers/scsi/sr_mod.o'.
   make[3]: *** No rule to make target 'drivers/scsi/sg.o', needed by 'drivers/scsi/built-in.o'.
   make[3]: *** No rule to make target 'drivers/scsi/ch.o', needed by 'drivers/scsi/built-in.o'.
   make[3]: *** No rule to make target 'drivers/scsi/ses.o', needed by 'drivers/scsi/built-in.o'.
   make[3]: *** [drivers/scsi/megaraid] Error 2
   make[3]: *** [drivers/scsi/arcmsr] Error 2
   make[3]: *** [drivers/scsi/esas2r] Error 2
   make[3]: *** [drivers/scsi/pm8001] Error 2
   make[3]: *** [drivers/scsi/mvsas] Error 2
   make[3]: *** [drivers/scsi/mpt3sas] Error 2
   make[3]: *** [drivers/scsi/aic94xx] Error 2
   make[3]: *** [drivers/scsi/aacraid] Error 2
   make[3]: *** [drivers/scsi/libsas] Error 2
   make[3]: *** [drivers/scsi/aic7xxx] Error 2
   make[3]: *** [drivers/scsi/snic] Error 2
   make[3]: Target '__build' not remade because of errors.

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
kernel test robot April 5, 2016, 12:31 p.m. UTC | #3
Hi Tomas,

[auto build test ERROR on char-misc/char-misc-testing]
[also build test ERROR on v4.6-rc2 next-20160405]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/Tomas-Winkler/Replay-Protected-Memory-Block-RPMB-subsystem/20160404-192243
config: x86_64-randconfig-s2-04051858 (attached as .config)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

   make[2]: *** No rule to make target 'lib/usercopy.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/lockref.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/bcd.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/div64.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/sort.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/parser.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/halfmd4.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/debug_locks.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/random32.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/bust_spinlocks.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/kasprintf.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/bitmap.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/scatterlist.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/gcd.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/lcm.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/list_sort.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/uuid.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/flex_array.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/iov_iter.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/clz_ctz.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/bsearch.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/find_bit.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/llist.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/memweight.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/kfifo.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/percpu-refcount.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/percpu_ida.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/rhashtable.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/reciprocal_div.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/once.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/string_helpers.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/test-string_helpers.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/hexdump.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/test_hexdump.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/kstrtox.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/test_firmware.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/test-kstrtox.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/test_rhashtable.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/test_printf.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/iomap.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/pci_iomap.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/iomap_copy.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/devres.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/check_signature.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/locking-selftest.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/hweight.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/assoc_array.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/bitrev.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/rational.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/crc-ccitt.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/crc16.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/crc-t10dif.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/crc-itu-t.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/crc7.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/libcrc32c.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/crc8.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/genalloc.o', needed by 'lib/built-in.o'.
   make[2]: *** [lib/reed_solomon] Error 2
   make[2]: *** [lib/842] Error 2
   make[2]: *** [lib/xz] Error 2
   make[2]: *** No rule to make target 'lib/bch.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/swiotlb.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/iommu-helper.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/iommu-common.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/fault-inject.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/notifier-error-inject.o', needed by 'lib/built-in.o'.
>> make[2]: *** No rule to make target 'lib/netdev-notifier-error-inject.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/syscall.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/nlattr.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/cordic.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/dynamic_queue_limits.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/strncpy_from_user.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/strnlen_user.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/net_utils.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/irq_poll.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/rbtree_test.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/asn1_decoder.o', needed by 'lib/built-in.o'.
   make[2]: *** [lib/lz4] Error 2
   make[2]: *** No rule to make target 'lib/ubsan.o', needed by 'lib/built-in.o'.
   make[2]: *** No rule to make target 'lib/argv_split.o', needed by 'lib/lib.a'.
   make[2]: *** No rule to make target 'lib/bug.o', needed by 'lib/lib.a'.
   make[2]: *** No rule to make target 'lib/clz_tab.o', needed by 'lib/lib.a'.
   make[2]: *** No rule to make target 'lib/cmdline.o', needed by 'lib/lib.a'.
   make[2]: *** No rule to make target 'lib/ctype.o', needed by 'lib/lib.a'.
   make[2]: *** No rule to make target 'lib/dec_and_lock.o', needed by 'lib/lib.a'.
   make[2]: *** No rule to make target 'lib/decompress.o', needed by 'lib/lib.a'.
   make[2]: *** No rule to make target 'lib/decompress_bunzip2.o', needed by 'lib/lib.a'.
   make[2]: *** No rule to make target 'lib/decompress_inflate.o', needed by 'lib/lib.a'.
   make[2]: *** No rule to make target 'lib/decompress_unlz4.o', needed by 'lib/lib.a'.
   make[2]: *** No rule to make target 'lib/decompress_unlzma.o', needed by 'lib/lib.a'.
   make[2]: *** No rule to make target 'lib/decompress_unlzo.o', needed by 'lib/lib.a'.
   make[2]: *** No rule to make target 'lib/decompress_unxz.o', needed by 'lib/lib.a'.
   make[2]: *** No rule to make target 'lib/dma-noop.o', needed by 'lib/lib.a'.
   make[2]: *** No rule to make target 'lib/dump_stack.o', needed by 'lib/lib.a'.
   make[2]: *** No rule to make target 'lib/earlycpio.o', needed by 'lib/lib.a'.
   make[2]: *** No rule to make target 'lib/extable.o', needed by 'lib/lib.a'.
   make[2]: *** No rule to make target 'lib/flex_proportions.o', needed by 'lib/lib.a'.
   make[2]: *** No rule to make target 'lib/idr.o', needed by 'lib/lib.a'.
   make[2]: *** No rule to make target 'lib/int_sqrt.o', needed by 'lib/lib.a'.
   make[2]: *** No rule to make target 'lib/ioremap.o', needed by 'lib/lib.a'.
   make[2]: *** No rule to make target 'lib/irq_regs.o', needed by 'lib/lib.a'.
   make[2]: *** No rule to make target 'lib/is_single_threaded.o', needed by 'lib/lib.a'.
   make[2]: *** No rule to make target 'lib/klist.o', needed by 'lib/lib.a'.
   make[2]: *** No rule to make target 'lib/kobject.o', needed by 'lib/lib.a'.
   make[2]: *** No rule to make target 'lib/kobject_uevent.o', needed by 'lib/lib.a'.
   make[2]: *** No rule to make target 'lib/md5.o', needed by 'lib/lib.a'.
   make[2]: *** No rule to make target 'lib/nmi_backtrace.o', needed by 'lib/lib.a'.
   make[2]: *** No rule to make target 'lib/plist.o', needed by 'lib/lib.a'.
   make[2]: *** No rule to make target 'lib/proportions.o', needed by 'lib/lib.a'.
   make[2]: *** No rule to make target 'lib/radix-tree.o', needed by 'lib/lib.a'.
   make[2]: *** No rule to make target 'lib/ratelimit.o', needed by 'lib/lib.a'.
   make[2]: *** No rule to make target 'lib/rbtree.o', needed by 'lib/lib.a'.
   make[2]: *** No rule to make target 'lib/seq_buf.o', needed by 'lib/lib.a'.
   make[2]: *** No rule to make target 'lib/sha1.o', needed by 'lib/lib.a'.
   make[2]: *** No rule to make target 'lib/show_mem.o', needed by 'lib/lib.a'.
   make[2]: *** No rule to make target 'lib/string.o', needed by 'lib/lib.a'.
   make[2]: *** No rule to make target 'lib/timerqueue.o', needed by 'lib/lib.a'.
   make[2]: *** No rule to make target 'lib/vsprintf.o', needed by 'lib/lib.a'.
   make[2]: *** [lib/lzo] Error 2
   make[2]: *** [lib/zlib_deflate] Error 2
   make[2]: *** [lib/zlib_inflate] Error 2
   make[2]: *** [lib/mpi] Error 2
   make[2]: Target '__build' not remade because of errors.
--
   make[3]: *** No rule to make target 'drivers/spi/spi.o', needed by 'drivers/spi/built-in.o'.
   make[3]: *** No rule to make target 'drivers/spi/spidev.o', needed by 'drivers/spi/built-in.o'.
   make[3]: *** No rule to make target 'drivers/spi/spi-altera.o', needed by 'drivers/spi/built-in.o'.
>> make[3]: *** No rule to make target 'drivers/spi/spi-axi-spi-engine.o', needed by 'drivers/spi/built-in.o'.
   make[3]: *** No rule to make target 'drivers/spi/spi-bitbang.o', needed by 'drivers/spi/built-in.o'.
   make[3]: *** No rule to make target 'drivers/spi/spi-cadence.o', needed by 'drivers/spi/built-in.o'.
>> make[3]: *** No rule to make target 'drivers/spi/spi-dln2.o', needed by 'drivers/spi/built-in.o'.
   make[3]: *** No rule to make target 'drivers/spi/spi-dw.o', needed by 'drivers/spi/built-in.o'.
   make[3]: *** No rule to make target 'drivers/spi/spi-fsl-lib.o', needed by 'drivers/spi/built-in.o'.
   make[3]: *** No rule to make target 'drivers/spi/spi-fsl-spi.o', needed by 'drivers/spi/built-in.o'.
   make[3]: *** No rule to make target 'drivers/spi/spi-sc18is602.o', needed by 'drivers/spi/built-in.o'.
   make[3]: *** No rule to make target 'drivers/spi/spi-tle62x0.o', needed by 'drivers/spi/built-in.o'.
>> make[3]: *** No rule to make target 'drivers/spi/spi-xcomm.o', needed by 'drivers/spi/built-in.o'.
   make[3]: *** No rule to make target 'drivers/spi/spi-zynqmp-gqspi.o', needed by 'drivers/spi/built-in.o'.
   make[3]: Target '__build' not remade because of errors.

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
Winkler, Tomas April 11, 2016, 10:50 a.m. UTC | #4
T24gVHVlLCAyMDE2LTA0LTA1IGF0IDIwOjE2ICswODAwLCBrYnVpbGQgdGVzdCByb2JvdCB3cm90
ZToNCj4gSGkgVG9tYXMsDQo+IA0KPiBbYXV0byBidWlsZCB0ZXN0IEVSUk9SIG9uIGNoYXItbWlz
Yy9jaGFyLW1pc2MtdGVzdGluZ10NCj4gW2Fsc28gYnVpbGQgdGVzdCBFUlJPUiBvbiB2NC42LXJj
MiBuZXh0LTIwMTYwNDA1XQ0KPiBbaWYgeW91ciBwYXRjaCBpcyBhcHBsaWVkIHRvIHRoZSB3cm9u
ZyBnaXQgdHJlZSwgcGxlYXNlIGRyb3AgdXMgYQ0KPiBub3RlIHRvIGhlbHAgaW1wcm92aW5nIHRo
ZSBzeXN0ZW1dDQo+IA0KPiB1cmw6wqDCoMKgwqBodHRwczovL2dpdGh1Yi5jb20vMGRheS1jaS9s
aW51eC9jb21taXRzL1RvbWFzLVdpbmtsZXIvUmVwbGF5DQo+IC1Qcm90ZWN0ZWQtTWVtb3J5LUJs
b2NrLVJQTUItc3Vic3lzdGVtLzIwMTYwNDA0LTE5MjI0Mw0KPiBjb25maWc6IHg4Nl82NC1yYW5k
Y29uZmlnLXMzLTA0MDUxODU4IChhdHRhY2hlZCBhcyAuY29uZmlnKQ0KPiByZXByb2R1Y2U6DQo+
IMKgwqDCoMKgwqDCoMKgwqAjIHNhdmUgdGhlIGF0dGFjaGVkIC5jb25maWcgdG8gbGludXggYnVp
bGQgdHJlZQ0KPiDCoMKgwqDCoMKgwqDCoMKgbWFrZSBBUkNIPXg4Nl82NMKgDQo+IA0KPiBBbGwg
ZXJyb3JzIChuZXcgb25lcyBwcmVmaXhlZCBieSA+Pik6DQo+IA0KPiDCoMKgwqBtYWtlWzNdOiAq
KiogTm8gcnVsZSB0byBtYWtlIHRhcmdldCAna2VybmVsL2djb3YvYmFzZS5vJywgbmVlZGVkDQo+
IGJ5ICdrZXJuZWwvZ2Nvdi9idWlsdC1pbi5vJy4NCj4gwqDCoMKgbWFrZVszXTogKioqIE5vIHJ1
bGUgdG8gbWFrZSB0YXJnZXQgJ2tlcm5lbC9nY292L2ZzLm8nLCBuZWVkZWQgYnkNCj4gJ2tlcm5l
bC9nY292L2J1aWx0LWluLm8nLg0KPiA+IA0KPiA+ID4gDQo+ID4gPiBtYWtlWzNdOiAqKiogTm8g
cnVsZSB0byBtYWtlIHRhcmdldCAna2VybmVsL2djb3YvZ2NjXzNfNC5vJywNCj4gPiA+IG5lZWRl
ZCBieSAna2VybmVsL2djb3YvYnVpbHQtaW4ubycuDQo+IMKgwqDCoG1ha2VbM106IFRhcmdldCAn
X19idWlsZCcgbm90IHJlbWFkZSBiZWNhdXNlIG9mIGVycm9ycy4NCj4gLS0NCj4gPiANCj4gPiA+
IA0KPiA+ID4gbWFrZVszXTogKioqIE5vIHJ1bGUgdG8gbWFrZSB0YXJnZXQgJ3Rvb2xzL29ianRv
b2wvb2JqdG9vbCcsDQo+ID4gPiBuZWVkZWQgYnkgJ2RyaXZlcnMvbWZkLzg4cG04MDAubycuDQo+
IMKgwqDCoG1ha2VbM106IFRhcmdldCAnX19idWlsZCcgbm90IHJlbWFkZSBiZWNhdXNlIG9mIGVy
cm9ycy4NCj4gLS0NCj4gPiANCj4gPiA+IA0KPiA+ID4gbWFrZVs0XTogKioqIE5vIHJ1bGUgdG8g
bWFrZSB0YXJnZXQgJ3Rvb2xzL29ianRvb2wvb2JqdG9vbCcsDQo+ID4gPiBuZWVkZWQgYnkgJ2Ry
aXZlcnMvZmlybXdhcmUvZ29vZ2xlL21lbWNvbnNvbGUubycuDQo+IMKgwqDCoG1ha2VbNF06IFRh
cmdldCAnX19idWlsZCcgbm90IHJlbWFkZSBiZWNhdXNlIG9mIGVycm9ycy4NCj4gLS0NCj4gPiAN
Cj4gPiA+IA0KPiA+ID4gbWFrZVs0XTogKioqIE5vIHJ1bGUgdG8gbWFrZSB0YXJnZXQgJ3Rvb2xz
L29ianRvb2wvb2JqdG9vbCcsDQo+ID4gPiBuZWVkZWQgYnkgJ2RyaXZlcnMvaWlvL2RhYy9hZDU2
MjRyX3NwaS5vJy4NCj4gwqDCoMKgbWFrZVs0XTogVGFyZ2V0ICdfX2J1aWxkJyBub3QgcmVtYWRl
IGJlY2F1c2Ugb2YgZXJyb3JzLg0KPiAtLQ0KPiA+IA0KPiA+ID4gDQo+ID4gPiBtYWtlWzRdOiAq
KiogTm8gcnVsZSB0byBtYWtlIHRhcmdldCAndG9vbHMvb2JqdG9vbC9vYmp0b29sJywNCj4gPiA+
IG5lZWRlZCBieSAnZHJpdmVycy9paW8vdHJpZ2dlci9paW8tdHJpZy1pbnRlcnJ1cHQubycuDQo+
IMKgwqDCoG1ha2VbNF06IFRhcmdldCAnX19idWlsZCcgbm90IHJlbWFkZSBiZWNhdXNlIG9mIGVy
cm9ycy4NCj4gLS0NCj4gPiANCj4gPiA+IA0KPiA+ID4gbWFrZVs0XTogKioqIE5vIHJ1bGUgdG8g
bWFrZSB0YXJnZXQgJ3Rvb2xzL29ianRvb2wvb2JqdG9vbCcsDQo+ID4gPiBuZWVkZWQgYnkgJ2Ry
aXZlcnMvaW5wdXQvam95c3RpY2svZ2Yyay5vJy4NCj4gwqDCoMKgbWFrZVs0XTogKioqIFtkcml2
ZXJzL2lucHV0L2pveXN0aWNrL2lmb3JjZV0gRXJyb3IgMg0KPiDCoMKgwqBtYWtlWzRdOiBUYXJn
ZXQgJ19fYnVpbGQnIG5vdCByZW1hZGUgYmVjYXVzZSBvZiBlcnJvcnMuDQo+IC0tDQo+ID4gDQo+
ID4gPiANCj4gPiA+IG1ha2VbNF06ICoqKiBObyBydWxlIHRvIG1ha2UgdGFyZ2V0ICd0b29scy9v
Ymp0b29sL29ianRvb2wnLA0KPiA+ID4gbmVlZGVkIGJ5ICdkcml2ZXJzL21pc2MvZWVwcm9tL21h
eDY4NzUubycuDQo+IMKgwqDCoG1ha2VbNF06IFRhcmdldCAnX19idWlsZCcgbm90IHJlbWFkZSBi
ZWNhdXNlIG9mIGVycm9ycy4NCj4gLS0NCj4gPiANCj4gPiA+IA0KPiA+ID4gbWFrZVs0XTogKioq
IE5vIHJ1bGUgdG8gbWFrZSB0YXJnZXQgJ3Rvb2xzL29ianRvb2wvb2JqdG9vbCcsDQo+ID4gPiBu
ZWVkZWQgYnkgJ2RyaXZlcnMvbW1jL2NhcmQvbW1jX3Rlc3QubycuDQo+IMKgwqDCoG1ha2VbNF06
IFRhcmdldCAnX19idWlsZCcgbm90IHJlbWFkZSBiZWNhdXNlIG9mIGVycm9ycy4NCj4gLS0NCj4g
PiANCj4gPiA+IA0KPiA+ID4gbWFrZVs0XTogKioqIE5vIHJ1bGUgdG8gbWFrZSB0YXJnZXQgJ3Rv
b2xzL29ianRvb2wvb2JqdG9vbCcsDQo+ID4gPiBuZWVkZWQgYnkgJ2RyaXZlcnMvbW1jL2hvc3Qv
c2RoY2kubycuDQo+IMKgwqDCoG1ha2VbNF06IFRhcmdldCAnX19idWlsZCcgbm90IHJlbWFkZSBi
ZWNhdXNlIG9mIGVycm9ycy4NCj4gLS0NCj4gPiANCj4gPiA+IA0KPiA+ID4gbWFrZVs0XTogKioq
IE5vIHJ1bGUgdG8gbWFrZSB0YXJnZXQgJ3Rvb2xzL29ianRvb2wvb2JqdG9vbCcsDQo+ID4gPiBu
ZWVkZWQgYnkgJ2RyaXZlcnMvcGluY3RybC9pbnRlbC9waW5jdHJsLWludGVsLm8nLg0KPiDCoMKg
wqBtYWtlWzRdOiBUYXJnZXQgJ19fYnVpbGQnIG5vdCByZW1hZGUgYmVjYXVzZSBvZiBlcnJvcnMu
DQo+IC0tDQo+ID4gDQo+ID4gPiANCj4gPiA+IG1ha2VbNF06ICoqKiBObyBydWxlIHRvIG1ha2Ug
dGFyZ2V0ICd0b29scy9vYmp0b29sL29ianRvb2wnLA0KPiA+ID4gbmVlZGVkIGJ5ICdkcml2ZXJz
L3BsYXRmb3JtL2Nocm9tZS9jaHJvbWVvc19sYXB0b3AubycuDQo+IMKgwqDCoG1ha2VbNF06IFRh
cmdldCAnX19idWlsZCcgbm90IHJlbWFkZSBiZWNhdXNlIG9mIGVycm9ycy4NCj4gLi4NCkp1c3Qg
dG8gcHV0IHRoYXQgc3RyYWlnaHQsIHRob3NlIGFyZSBpc3N1ZXMgaW4gdGhlIHRlc3RpbmcgZW52
aXJvbm1lbnQNCm5vdCBpbiB0aGUgcGF0Y2hlcy4NCg0KVGhhbmtzDQpUb21hcw0K
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Josh Poimboeuf April 11, 2016, 1:33 p.m. UTC | #5
Hi Tomas,

On Mon, Apr 04, 2016 at 02:11:22PM +0300, Tomas Winkler wrote:
> Add simple RPMB host testing tool. It can be used
> to program key, write and read data block, and retrieve
> write counter.
> 
> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
> ---
> V2: resend
>  MAINTAINERS           |   1 +
>  tools/Makefile        |  16 +-
>  tools/rpmb/.gitignore |   2 +
>  tools/rpmb/Makefile   |  32 ++
>  tools/rpmb/rpmb.c     | 807 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  5 files changed, 853 insertions(+), 5 deletions(-)
>  create mode 100644 tools/rpmb/.gitignore
>  create mode 100644 tools/rpmb/Makefile
>  create mode 100644 tools/rpmb/rpmb.c
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 07bd6f380460..b7966b95c265 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -9425,6 +9425,7 @@ F:	drivers/char/rpmb/*
>  F:	include/uapi/linux/rpmb.h
>  F:	include/linux/rpmb.h
>  F:	Documentation/ABI/testing/sysfs-class-rpmb
> +F:	tools/rpmb/
>  
>  RTL2830 MEDIA DRIVER
>  M:	Antti Palosaari <crope@iki.fi>
> diff --git a/tools/Makefile b/tools/Makefile
> index 60c7e6c8ff17..5b37ccd95cab 100644
> --- a/tools/Makefile
> +++ b/tools/Makefile
> @@ -19,6 +19,7 @@ help:
>  	@echo '  lguest                 - a minimal 32-bit x86 hypervisor'
>  	@echo '  net                    - misc networking tools'
>  	@echo '  perf                   - Linux performance measurement and analysis tool'
> +	@echo '  rpmb                   - Replay protected memory block access tool'
>  	@echo '  selftests              - various kernel selftests'
>  	@echo '  spi                    - spi tools'
>  	@echo '  objtool                - an ELF object analysis tool'
> @@ -55,7 +56,8 @@ acpi: FORCE
>  cpupower: FORCE
>  	$(call descend,power/$@)
>  
> -cgroup firewire hv guest spi usb virtio vm net iio gpio objtool: FORCE
> +cgroup firewire hv guest rpmb spi usb virtio vm net iio gpio objtool: FORCE
> +cgroup firewire hv guest rpmb spi usb virtio vm net iio: FORCE

This looks like an artifact from a bad merge resolution.  The second
line needs to be deleted.  This probably explains the kbuild robot build
errors, since CONFIG_STACK_VALIDATION requires objtool to be built.

>  	$(call descend,$@)
>  
>  liblockdep: FORCE
> @@ -85,7 +87,7 @@ freefall: FORCE
>  	$(call descend,laptop/$@)
>  
>  all: acpi cgroup cpupower hv firewire lguest \
> -		perf selftests turbostat usb \
> +		perf rpmb selftests turbostat usb \
>  		virtio vm net x86_energy_perf_policy \
>  		tmon freefall objtool
>  
> @@ -95,7 +97,8 @@ acpi_install:
>  cpupower_install:
>  	$(call descend,power/$(@:_install=),install)
>  
> -cgroup_install firewire_install hv_install lguest_install perf_install usb_install virtio_install vm_install net_install objtool_install:
> +cgroup_install firewire_install hv_install lguest_install perf_install rpmb_install usb_install virtio_install vm_install net_install objtool_install:
> +cgroup_install firewire_install hv_install lguest_install perf_install rpmb_install usb_install virtio_install vm_install net_install:

Same here.
diff mbox

Patch

diff --git a/MAINTAINERS b/MAINTAINERS
index 07bd6f380460..b7966b95c265 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -9425,6 +9425,7 @@  F:	drivers/char/rpmb/*
 F:	include/uapi/linux/rpmb.h
 F:	include/linux/rpmb.h
 F:	Documentation/ABI/testing/sysfs-class-rpmb
+F:	tools/rpmb/
 
 RTL2830 MEDIA DRIVER
 M:	Antti Palosaari <crope@iki.fi>
diff --git a/tools/Makefile b/tools/Makefile
index 60c7e6c8ff17..5b37ccd95cab 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -19,6 +19,7 @@  help:
 	@echo '  lguest                 - a minimal 32-bit x86 hypervisor'
 	@echo '  net                    - misc networking tools'
 	@echo '  perf                   - Linux performance measurement and analysis tool'
+	@echo '  rpmb                   - Replay protected memory block access tool'
 	@echo '  selftests              - various kernel selftests'
 	@echo '  spi                    - spi tools'
 	@echo '  objtool                - an ELF object analysis tool'
@@ -55,7 +56,8 @@  acpi: FORCE
 cpupower: FORCE
 	$(call descend,power/$@)
 
-cgroup firewire hv guest spi usb virtio vm net iio gpio objtool: FORCE
+cgroup firewire hv guest rpmb spi usb virtio vm net iio gpio objtool: FORCE
+cgroup firewire hv guest rpmb spi usb virtio vm net iio: FORCE
 	$(call descend,$@)
 
 liblockdep: FORCE
@@ -85,7 +87,7 @@  freefall: FORCE
 	$(call descend,laptop/$@)
 
 all: acpi cgroup cpupower hv firewire lguest \
-		perf selftests turbostat usb \
+		perf rpmb selftests turbostat usb \
 		virtio vm net x86_energy_perf_policy \
 		tmon freefall objtool
 
@@ -95,7 +97,8 @@  acpi_install:
 cpupower_install:
 	$(call descend,power/$(@:_install=),install)
 
-cgroup_install firewire_install hv_install lguest_install perf_install usb_install virtio_install vm_install net_install objtool_install:
+cgroup_install firewire_install hv_install lguest_install perf_install rpmb_install usb_install virtio_install vm_install net_install objtool_install:
+cgroup_install firewire_install hv_install lguest_install perf_install rpmb_install usb_install virtio_install vm_install net_install:
 	$(call descend,$(@:_install=),install)
 
 selftests_install:
@@ -111,7 +114,7 @@  freefall_install:
 	$(call descend,laptop/$(@:_install=),install)
 
 install: acpi_install cgroup_install cpupower_install hv_install firewire_install lguest_install \
-		perf_install selftests_install turbostat_install usb_install \
+		perf_install rpmb_install selftests_install turbostat_install usb_install \
 		virtio_install vm_install net_install x86_energy_perf_policy_install \
 		tmon_install freefall_install objtool_install
 
@@ -139,6 +142,9 @@  libsubcmd_clean:
 perf_clean:
 	$(call descend,$(@:_clean=),clean)
 
+rpmb_clean:
+	$(call descend,$(@:_clean=),clean)
+
 selftests_clean:
 	$(call descend,testing/$(@:_clean=),clean)
 
@@ -155,7 +161,7 @@  build_clean:
 	$(call descend,build,clean)
 
 clean: acpi_clean cgroup_clean cpupower_clean hv_clean firewire_clean lguest_clean \
-		perf_clean selftests_clean turbostat_clean spi_clean usb_clean virtio_clean \
+		perf_clean rpmb_clean selftests_clean turbostat_clean spi_clean usb_clean virtio_clean \
 		vm_clean net_clean iio_clean x86_energy_perf_policy_clean tmon_clean \
 		freefall_clean build_clean libbpf_clean libsubcmd_clean liblockdep_clean \
 		gpio_clean objtool_clean
diff --git a/tools/rpmb/.gitignore b/tools/rpmb/.gitignore
new file mode 100644
index 000000000000..218f680548e6
--- /dev/null
+++ b/tools/rpmb/.gitignore
@@ -0,0 +1,2 @@ 
+*.o
+rpmb
diff --git a/tools/rpmb/Makefile b/tools/rpmb/Makefile
new file mode 100644
index 000000000000..e0e51f306dac
--- /dev/null
+++ b/tools/rpmb/Makefile
@@ -0,0 +1,32 @@ 
+CC = $(CROSS_COMPILE)gcc
+LD = $(CROSS_COMPILE)ld
+PKG_CONFIG = $(CROSS_COMPILE)pkg-config
+
+ifeq ($(srctree),)
+srctree := $(patsubst %/,%,$(dir $(shell pwd)))
+srctree := $(patsubst %/,%,$(dir $(srctree)))
+#$(info Determined 'srctree' to be $(srctree))
+endif
+
+INSTALL = install
+prefix ?= /usr/local
+bindir = $(prefix)/bin
+
+
+CFLAGS += -D__EXPORTED_HEADERS__
+CFLAGS += -I$(srctree)/include/uapi -I$(srctree)/include
+LDLIBS += $(shell $(PKG_CONFIG) --libs libcrypto)
+
+prog := rpmb
+
+all : $(prog)
+
+$(prog): rpmb.o
+
+clean :
+	$(RM) $(prog) *.o
+
+install: $(prog)
+	$(INSTALL) -m755 -d $(DESTDIR)$(bindir)
+	$(INSTALL) $(prog) $(DESTDIR)$(bindir)
+
diff --git a/tools/rpmb/rpmb.c b/tools/rpmb/rpmb.c
new file mode 100644
index 000000000000..e55f4d4e7ef7
--- /dev/null
+++ b/tools/rpmb/rpmb.c
@@ -0,0 +1,807 @@ 
+/******************************************************************************
+ * This file is provided under a dual BSD/GPLv2 license.  When using or
+ * redistributing this file, you may do so under either license.
+ *
+ * GPL LICENSE SUMMARY
+ *
+ * Copyright(c) 2016 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * The full GNU General Public License is included in this distribution
+ * in the file called LICENSE.GPL.
+ *
+ * Contact Information:
+ *	Intel Corporation.
+ *	linux-mei@linux.intel.com
+ *	http://www.intel.com
+ *
+ * BSD LICENSE
+ *
+ * Copyright(c) 2016 Intel Corporation. All rights reserved.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *  * Neither the name Intel Corporation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *****************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <libgen.h>
+#include <limits.h>
+#include <ctype.h>
+#include <errno.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <openssl/engine.h>
+#include <openssl/hmac.h>
+
+#include "linux/rpmb.h"
+
+#define RPMB_KEY_SIZE 32
+#define RPMB_MAC_SIZE 32
+#define RPMB_NONCE_SIZE 16
+
+#define rpmb_msg(fmt, ARGS...) \
+	fprintf(stderr, "rpmb: " fmt, ##ARGS)
+
+#define rpmb_err(fmt, ARGS...) \
+	fprintf(stderr, "rpmb: error: " fmt, ##ARGS)
+
+static const char *rpmb_op_str(uint16_t op)
+{
+#define RPMB_OP(_op) case RPMB_##_op: return #_op
+
+	switch (op) {
+	RPMB_OP(PROGRAM_KEY);
+	RPMB_OP(GET_WRITE_COUNTER);
+	RPMB_OP(WRITE_DATA);
+	RPMB_OP(READ_DATA);
+	RPMB_OP(RESULT_READ);
+	break;
+	default:
+		return "unknown";
+	}
+}
+
+static const char *rpmb_result_str(enum rpmb_op_result result)
+{
+#define str(x) #x
+#define RPMB_ERR(_res) case RPMB_ERR_##_res:         \
+	{ if (result & RPMB_ERR_COUNTER_EXPIRED)     \
+		return "COUNTER_EXPIRE:" str(_res);  \
+	else                                         \
+		return #_res;                        \
+	}
+
+	switch (result & 0x000F) {
+	RPMB_ERR(OK);
+	RPMB_ERR(GENERAL);
+	RPMB_ERR(AUTH);
+	RPMB_ERR(COUNTER);
+	RPMB_ERR(ADDRESS);
+	RPMB_ERR(WRITE);
+	RPMB_ERR(READ);
+	RPMB_ERR(NO_KEY);
+	break;
+	default:
+		return "unknown";
+	}
+#undef RPMB_ERR
+};
+
+static inline void __dump_buffer(const char *buf)
+{
+	fprintf(stderr, "%s\n", buf);
+}
+static void rpmb_dump_hex_buffer(const unsigned char *buf, size_t len)
+{
+	const size_t pbufsz = 16 * 3;
+	char pbuf[pbufsz];
+	int j = 0;
+
+	while (len-- > 0) {
+		snprintf(&pbuf[j], pbufsz - j, "%02X ", *buf++);
+		j += 3;
+		if (j == 16 * 3) {
+			__dump_buffer(pbuf);
+			j = 0;
+		}
+	}
+	if (j)
+		__dump_buffer(pbuf);
+}
+
+static int open_dev_file(const char *devfile)
+{
+	int fd;
+
+	fd = open(devfile, O_RDWR);
+	if (fd < 0)
+		rpmb_err("Cannot open: %s: %s\n", devfile, strerror(errno));
+	return fd;
+}
+
+static int open_rd_file(const char *datafile, const char *type)
+{
+	int fd;
+
+	if (!strcmp(datafile, "-"))
+		fd = STDIN_FILENO;
+	else
+		fd = open(datafile, O_RDONLY);
+
+	if (fd < 0)
+		rpmb_err("Cannot open %s: %s: %s\n",
+			type, datafile, strerror(errno));
+
+	return fd;
+}
+
+static int open_wr_file(const char *datafile, const char *type)
+{
+	int fd;
+
+	if (!strcmp(datafile, "-"))
+		fd = STDOUT_FILENO;
+	else
+		fd = open(datafile, O_WRONLY | O_CREAT | O_APPEND,
+					   S_IRUSR | S_IWUSR);
+	if (fd < 0)
+		rpmb_err("Cannot open %s: %s: %s\n",
+			type, datafile, strerror(errno));
+	return fd;
+}
+
+static void close_fd(int fd)
+{
+	if (fd > 0 && fd != STDIN_FILENO && fd != STDOUT_FILENO)
+		close(fd);
+}
+
+/* blocking rw wrapper */
+#define rw(func, fd, buf, size)                              \
+({                                                           \
+	ssize_t nread = 0, n;                                \
+	char *_buf = (char *)buf;                            \
+	do {                                                 \
+		n = func(fd, _buf + nread, size - nread);    \
+		if (n == -1 && errno != EINTR) {             \
+			nread = -1;                          \
+			break;                               \
+		} else if (n > 0) {                          \
+			nread += n;                          \
+		}                                            \
+	} while (n != 0 && (size_t)nread != size);           \
+	nread;                                               \
+})
+
+
+static ssize_t read_file(int fd, unsigned char *data, size_t size)
+{
+	ssize_t ret;
+
+	ret = rw(read, fd, data, size);
+	if (ret < 0) {
+		rpmb_err("cannot read file: %s\n", strerror(errno));
+	} else if (ret != size) {
+		rpmb_err("read %zd but must be %zu bytes length\n",
+			ret, size);
+		ret = -EINVAL;
+	}
+
+	return ret;
+}
+
+static ssize_t write_file(int fd, unsigned char *data, size_t size)
+{
+	ssize_t ret;
+
+	ret = rw(write, fd, data, size);
+	if (ret < 0) {
+		rpmb_err("cannot read file: %s\n", strerror(errno));
+	} else if (ret != size) {
+		rpmb_err("data is %zd but must be %zu bytes length\n",
+			ret, size);
+		ret = -EINVAL;
+	}
+	return ret;
+}
+
+static int rpmb_calc_hmac_sha256(struct rpmb_frame *frames, size_t blocks_cnt,
+				 const unsigned char key[],
+				 unsigned int key_size,
+				 unsigned char mac[],
+				 unsigned int mac_size)
+{
+	HMAC_CTX ctx;
+	int ret;
+	int i;
+
+	 /* SSL returns 1 on success 0 on failure */
+
+	HMAC_CTX_init(&ctx);
+	ret = HMAC_Init_ex(&ctx, key, key_size, EVP_sha256(), NULL);
+	if (ret == 0)
+		goto out;
+	for (i = 0; i < blocks_cnt; i++)
+		HMAC_Update(&ctx, frames[i].data, hmac_data_len);
+
+	ret = HMAC_Final(&ctx, mac, &mac_size);
+	if (ret == 0)
+		goto out;
+	if (mac_size != RPMB_MAC_SIZE)
+		ret = 0;
+
+	ret = 1;
+out:
+	HMAC_CTX_cleanup(&ctx);
+	return ret == 1 ? 0 : -1;
+}
+
+static int rpmb_ioctl(int fd, uint16_t req,
+	const struct rpmb_frame *frames_in,
+	unsigned int in_cnt,
+	struct rpmb_frame *frames_out,
+	unsigned int out_cnt)
+{
+	int ret;
+	struct rpmb_ioc_cmd icmd;
+
+	icmd.req = req;
+	icmd.in_frames_count = in_cnt;
+	rpmb_ioc_cmd_set_in_frames(icmd, frames_in);
+	rpmb_ioc_cmd_set_out_frames(icmd, frames_out);
+	icmd.out_frames_count = out_cnt;
+
+	ret = ioctl(fd, RPMB_IOC_REQ, &icmd);
+	if (ret < 0)
+		rpmb_err("ioctl failure %d: %s\n", ret, strerror(errno));
+
+	return ret;
+}
+
+
+static int op_rpmb_program_key(int nargs, char *argv[])
+{
+	int ret;
+	int  dev_fd = -1, key_fd = -1;
+	uint16_t req = RPMB_PROGRAM_KEY;
+	struct rpmb_frame frame_in, frame_out;
+
+	ret = -EINVAL;
+	if (nargs != 2)
+		return ret;
+
+	dev_fd = open_dev_file(argv[0]);
+	if (dev_fd < 0)
+		goto out;
+	argv++;
+
+	key_fd = open_rd_file(argv[0], "key file");
+	if (key_fd < 0)
+		goto out;
+	argv++;
+
+	memset(&frame_in, 0, sizeof(frame_in));
+	frame_in.req_resp = htobe16(req);
+
+	read_file(key_fd, frame_in.key_mac, RPMB_KEY_SIZE);
+
+	ret = rpmb_ioctl(dev_fd, req, &frame_in, 1, &frame_out, 1);
+	if (ret)
+		goto out;
+
+	ret = be16toh(frame_out.result);
+	if (ret)
+		rpmb_err("RPMB operation %s failed, %s[0x%04x]\n",
+			 rpmb_op_str(req), rpmb_result_str(ret), ret);
+
+out:
+	close_fd(dev_fd);
+	close_fd(key_fd);
+
+	return ret;
+}
+
+static int rpmb_get_write_counter(int dev_fd, unsigned int *cnt,
+				  const unsigned char *key)
+{
+	int ret;
+	uint16_t req = RPMB_GET_WRITE_COUNTER;
+	unsigned char mac[RPMB_MAC_SIZE];
+	struct rpmb_frame frame_in;
+	struct rpmb_frame frame_out;
+
+	memset(&frame_in, 0, sizeof(frame_in));
+	frame_in.req_resp = htobe16(req);
+	RAND_bytes(frame_in.nonce, RPMB_NONCE_SIZE);
+
+	ret = rpmb_ioctl(dev_fd, req, &frame_in, 1, &frame_out, 1);
+	if (ret != 0)
+		return ret;
+
+	ret = be16toh(frame_out.result);
+	if (ret)
+		goto out;
+
+	if (key) {
+		rpmb_calc_hmac_sha256(&frame_out, 1,
+				      key, RPMB_KEY_SIZE,
+				      mac, RPMB_MAC_SIZE);
+		if (memcmp(mac, frame_out.key_mac, RPMB_MAC_SIZE)) {
+			rpmb_err("RPMB hmac mismatch\n");
+			rpmb_dump_hex_buffer(frame_out.key_mac, RPMB_MAC_SIZE);
+			rpmb_dump_hex_buffer(mac, RPMB_MAC_SIZE);
+			ret = RPMB_ERR_AUTH;
+			goto out;
+		}
+	}
+
+	*cnt = be32toh(frame_out.write_counter);
+
+out:
+	if (ret) {
+		rpmb_err("RPMB operation %s failed, %s[0x%04x]\n",
+			 rpmb_op_str(req), rpmb_result_str(ret), ret);
+	}
+	return ret;
+}
+
+static int op_rpmb_get_write_counter(int nargs, char **argv)
+{
+	int ret;
+	int dev_fd = -1, key_fd = -1;
+	bool has_key;
+	unsigned char key[RPMB_KEY_SIZE];
+	unsigned int cnt;
+
+	if (nargs == 2)
+		has_key = true;
+	else if (nargs == 1)
+		has_key = false;
+	else
+		return -EINVAL;
+
+	ret = -EINVAL;
+	dev_fd = open_dev_file(argv[0]);
+	if (dev_fd < 0)
+		return ret;
+	argv++;
+
+	if (has_key) {
+		key_fd = open_rd_file(argv[0], "key file");
+		if (key_fd < 0)
+			goto out;
+		argv++;
+
+		ret = read_file(key_fd, key, RPMB_KEY_SIZE);
+		if (ret < 0)
+			goto out;
+
+		ret = rpmb_get_write_counter(dev_fd, &cnt, key);
+	} else {
+		ret = rpmb_get_write_counter(dev_fd, &cnt, NULL);
+	}
+
+	if (!ret)
+		printf("Counter value: 0x%08x\n", cnt);
+
+out:
+	close_fd(dev_fd);
+	close_fd(key_fd);
+	return ret;
+}
+
+static int op_rpmb_read_blocks(int nargs, char **argv)
+{
+	int i, ret;
+	int dev_fd = -1, data_fd = -1, key_fd = -1;
+	uint16_t req = RPMB_READ_DATA;
+	uint16_t addr, blocks_cnt;
+	unsigned char key[RPMB_KEY_SIZE];
+	unsigned char mac[RPMB_MAC_SIZE];
+	unsigned long numarg;
+	bool has_key;
+	struct rpmb_frame frame_in;
+	struct rpmb_frame *frames_out = NULL;
+	struct rpmb_frame *frame_out;
+
+	ret = -EINVAL;
+	if (nargs == 4)
+		has_key = false;
+	else if (nargs == 5)
+		has_key = true;
+	else
+		return ret;
+
+	dev_fd = open_dev_file(argv[0]);
+	if (dev_fd < 0)
+		goto out;
+	argv++;
+
+	errno = 0;
+	numarg = strtoul(argv[0], NULL, 0);
+	if (errno || numarg > USHRT_MAX) {
+		rpmb_err("wrong block address\n");
+		goto out;
+	}
+	addr = (uint16_t)numarg;
+	argv++;
+
+	errno = 0;
+	numarg = strtoul(argv[0], NULL, 0);
+	if (errno || numarg > USHRT_MAX) {
+		rpmb_err("wrong blocks count\n");
+		goto out;
+	}
+	blocks_cnt = (uint16_t)numarg;
+	argv++;
+
+	if (blocks_cnt == 0) {
+		rpmb_err("wrong blocks count\n");
+		goto out;
+	}
+
+	data_fd = open_wr_file(argv[0], "output data");
+	if (data_fd < 0)
+		goto out;
+	argv++;
+
+	if (has_key) {
+		key_fd = open_rd_file(argv[0], "key file");
+		if (key_fd < 0)
+			goto out;
+		argv++;
+
+		ret = read_file(key_fd, key, RPMB_KEY_SIZE);
+		if (ret < 0)
+			goto out;
+	}
+
+	ret = 0;
+	memset(&frame_in, 0, sizeof(frame_in));
+	frame_in.req_resp = htobe16(req);
+	frame_in.addr = htobe16(addr);
+	frame_in.block_count = htobe16(blocks_cnt);
+	if (has_key)
+		RAND_bytes(frame_in.nonce, RPMB_NONCE_SIZE);
+
+	frames_out = calloc(blocks_cnt, sizeof(struct rpmb_frame));
+	if (!frames_out) {
+		rpmb_err("Cannot allocate %d RPMB frames\n", blocks_cnt);
+		ret = -ENOMEM;
+		goto out;
+	}
+
+	ret = rpmb_ioctl(dev_fd, req, &frame_in, 1, frames_out, blocks_cnt);
+	if (ret)
+		goto out;
+
+	frame_out = &frames_out[blocks_cnt - 1];
+	ret = be16toh(frame_out->result);
+	if (ret) {
+		rpmb_err("RPMB operation %s failed, %s[0x%04x]\n",
+			 rpmb_op_str(req), rpmb_result_str(ret), ret);
+		goto out;
+	}
+
+	if (has_key) {
+		rpmb_calc_hmac_sha256(frames_out, blocks_cnt,
+				      key, RPMB_KEY_SIZE,
+				      mac, RPMB_MAC_SIZE);
+		if (memcmp(mac, frame_out->key_mac, RPMB_MAC_SIZE)) {
+			rpmb_err("RPMB hmac mismatch\n");
+			rpmb_dump_hex_buffer(frame_out->key_mac, RPMB_MAC_SIZE);
+			rpmb_dump_hex_buffer(mac, RPMB_MAC_SIZE);
+			ret = RPMB_ERR_AUTH;
+			goto out;
+		}
+	}
+
+	for (i = 0; i < blocks_cnt; i++) {
+		ret = write_file(data_fd,
+				frames_out[i].data, sizeof(frames_out[i].data));
+		if (ret < 0)
+			goto out;
+	}
+
+out:
+	free(frames_out);
+	close_fd(dev_fd);
+	close_fd(data_fd);
+	close_fd(key_fd);
+
+	return ret;
+}
+
+static int op_rpmb_write_blocks(int nargs, char **argv)
+{
+	int ret;
+	int dev_fd = -1, key_fd = -1, data_fd = -1;
+	int i;
+	uint16_t req = RPMB_WRITE_DATA;
+	unsigned char key[RPMB_KEY_SIZE];
+	unsigned char mac[RPMB_MAC_SIZE];
+	unsigned long numarg;
+	uint16_t addr, blocks_cnt;
+	unsigned int cnt;
+	struct rpmb_frame *frames_in;
+	struct rpmb_frame frame_out;
+
+	ret = -EINVAL;
+	if (nargs != 5)
+		goto out;
+
+	dev_fd = open_dev_file(argv[0]);
+	if (dev_fd < 0)
+		goto out;
+	argv++;
+
+	errno = 0;
+	numarg = strtoul(argv[0], NULL, 0);
+	if (errno || numarg > USHRT_MAX) {
+		rpmb_err("wrong block address %s\n", argv[0]);
+		goto out;
+	}
+	addr = (uint16_t)numarg;
+	argv++;
+
+	errno = 0;
+	numarg = strtoul(argv[0], NULL, 0);
+	if (errno || numarg > USHRT_MAX) {
+		rpmb_err("wrong blocks count\n");
+		goto out;
+	}
+	blocks_cnt = (uint16_t)numarg;
+	argv++;
+
+	if (blocks_cnt == 0) {
+		rpmb_err("wrong blocks count\n");
+		goto out;
+	}
+
+	data_fd = open_rd_file(argv[0], "data file");
+	if (data_fd < 0)
+		goto out;
+	argv++;
+
+	key_fd = open_rd_file(argv[0], "key file");
+	if (key_fd < 0)
+		goto out;
+	argv++;
+
+	ret = read_file(key_fd, key, RPMB_KEY_SIZE);
+	if (ret < 0)
+		goto out;
+
+	frames_in = calloc(blocks_cnt, sizeof(struct rpmb_frame));
+	if (!frames_in) {
+		rpmb_err("can't allocate memory for RPMB outer frames\n");
+		exit(EXIT_FAILURE);
+	}
+
+	ret = rpmb_get_write_counter(dev_fd, &cnt, key);
+	if (ret)
+		goto out;
+
+	for (i = 0; i < blocks_cnt; i++) {
+		frames_in[i].req_resp      = htobe16(req);
+		frames_in[i].block_count   = htobe16(blocks_cnt);
+		frames_in[i].addr          = htobe16(addr);
+		frames_in[i].write_counter = htobe32(cnt);
+	}
+
+	for (i = 0; i < blocks_cnt; i++) {
+		ret = read_file(data_fd, frames_in[i].data,
+				sizeof(frames_in[0].data));
+		if (ret < 0)
+			goto out;
+	}
+
+	rpmb_calc_hmac_sha256(frames_in, blocks_cnt,
+			      key, RPMB_KEY_SIZE,
+			      mac, RPMB_MAC_SIZE);
+	memcpy(frames_in[blocks_cnt - 1].key_mac, mac, RPMB_MAC_SIZE);
+	ret = rpmb_ioctl(dev_fd, req, frames_in, blocks_cnt, &frame_out, 1);
+	if (ret != 0)
+		goto out;
+
+	ret = be16toh(frame_out.result);
+	if (ret) {
+		rpmb_err("RPMB operation %s failed, %s[0x%04x]\n",
+			 rpmb_op_str(req), rpmb_result_str(ret), ret);
+	}
+out:
+	close_fd(dev_fd);
+	close_fd(data_fd);
+	close_fd(key_fd);
+	return ret;
+}
+
+typedef int (*rpmb_op)(int argc, char *argv[]);
+
+struct rpmb_cmd {
+	const char *op_name;
+	rpmb_op     op;
+	const char  *usage; /* usage title */
+	const char  *help;  /* help */
+};
+
+
+static const struct rpmb_cmd cmds[] = {
+	{
+	 "program-key",
+	 op_rpmb_program_key,
+	 "<RPMB_DEVICE> <KEY_FILE>",
+	 "    Program authentication key of 32 bytes length from the KEY_FILE\n"
+	 "    when KEY_FILE is -, read standard input.\n"
+	 "    NOTE: This is a one-time programmable irreversible change.\n",
+	},
+	{
+	 "write-counter",
+	 op_rpmb_get_write_counter,
+	 "<RPMB_DEVICE> [KEY_FILE]",
+	 "    Rertrive write counter value from the <RPMB_DEVICE> to stdout.\n"
+	 "    When KEY_FILE is present data is verified via HMAC\n"
+	 "    when KEY_FILE is -, read standard input.\n"
+	},
+	{
+	  "write-blocks",
+	  op_rpmb_write_blocks,
+	  "<RPMB_DEVICE> <address> <block_count> <DATA_FILE> <KEY_FILE>",
+	  "    <block count> of 256 bytes will be written from the DATA_FILE\n"
+	  "    to the <RPMB_DEVICE> at block offset <address>.\n"
+	  "    When DATA_FILE is -, read from standard input.\n",
+	},
+	{
+	  "read-blocks",
+	  op_rpmb_read_blocks,
+	  "<RPMB_DEVICE> <address> <blocks count> <OUTPUT_FILE> [KEY_FILE]",
+	  "    <block count> of 256 bytes will be read from <RPMB_DEVICE>\n"
+	  "    to the OUTPUT_FILE\n"
+	  "    When KEY_FILE is present data is verified via HMAC\n"
+	  "    When OUTPUT/KEY_FILE is -, read from standard input.\n"
+	  "    When OUTPUT_FILE is -, write to standard output\n",
+	},
+
+	{ NULL, NULL, NULL, NULL }
+};
+
+static void help(const char *prog, const struct rpmb_cmd *cmd)
+{
+	printf("%s %s %s\n", prog, cmd->op_name, cmd->usage);
+	printf("%s\n", cmd->help);
+}
+
+static void usage(const char *prog)
+{
+	int i;
+
+	printf("\n");
+	printf("Usage: %s <command> <args>\n\n", prog);
+	for (i = 0; cmds[i].op_name; i++)
+		printf("       %s %s %s\n",
+			prog, cmds[i].op_name, cmds[i].usage);
+
+	printf("\n");
+	printf("      %s help : shows this help\n", prog);
+	printf("      %s help <command>: shows detailed help\n", prog);
+}
+
+static bool call_for_help(const char *arg)
+{
+	return !strcmp(arg, "help") ||
+	       !strcmp(arg, "-h")   ||
+	       !strcmp(arg, "--help");
+}
+
+static const
+struct rpmb_cmd *parse_args(const char *prog, int *_argc, char **_argv[])
+{
+
+	int i;
+	int argc = *_argc;
+	char **argv =  *_argv;
+	const struct rpmb_cmd *cmd = NULL;
+	bool need_help = false;
+
+	argc--; argv++;
+
+	if (argc == 0)
+		goto out;
+
+	if (call_for_help(argv[0])) {
+		argc--; argv++;
+		if (argc == 0)
+			goto out;
+		else
+			need_help = true;
+	}
+
+	for (i = 0; cmds[i].op_name; i++) {
+		if (!strncmp(argv[0], cmds[i].op_name,
+			     strlen(cmds[i].op_name))) {
+			cmd = &cmds[i];
+			argc--; argv++;
+			break;
+		}
+	}
+
+	if (!cmd)
+		goto out;
+
+	if (need_help || (argc > 0 && call_for_help(argv[0]))) {
+		help(prog, cmd);
+		argc--; argv++;
+		return NULL;
+	}
+
+out:
+	*_argc = argc;
+	*_argv = argv;
+
+	if (!cmd)
+		usage(prog);
+
+	return cmd;
+}
+
+int main(int argc, char *argv[])
+{
+	const char *prog = basename(argv[0]);
+	const struct rpmb_cmd *cmd;
+	int ret;
+
+	cmd = parse_args(prog, &argc, &argv);
+	if (!cmd)
+		exit(EXIT_SUCCESS);
+
+	ret = cmd->op(argc, argv);
+	if (ret == -EINVAL)
+		help(prog, cmd);
+
+	if (ret)
+		exit(EXIT_FAILURE);
+
+	exit(EXIT_SUCCESS);
+}