12 Mar, 2020

1 commit

  • This patch changes the check condition for the validity/authentication
    of the session.

    1. The Host Session Number(HSN) in the response should match the HSN for
    the session.
    2. The TPER Session Number(TSN) can never be less than 4096 for a regular
    session.

    Reference:
    Section 3.2.2.1 of https://trustedcomputinggroup.org/wp-content/uploads/TCG_Storage_Opal_SSC_Application_Note_1-00_1-00-Final.pdf
    Section 3.3.7.1.1 of https://trustedcomputinggroup.org/wp-content/uploads/TCG_Storage_Architecture_Core_Spec_v2.01_r1.00.pdf

    Co-developed-by: Andrzej Jakowski
    Signed-off-by: Andrzej Jakowski
    Signed-off-by: Revanth Rajashekar
    Signed-off-by: Jens Axboe

    Revanth Rajashekar
     

19 Nov, 2019

1 commit

  • In function 'activate_lsp', rather than hard-coding the short atom
    header(0x83), we need to let the function 'add_short_atom_header' append
    the header based on the parameter being appended.

    The parameter has been defined in Section 3.1.2.1 of
    https://trustedcomputinggroup.org/wp-content/uploads/TCG_Storage-Opal_Feature_Set_Single_User_Mode_v1-00_r1-00-Final.pdf

    Reviewed-by: Jon Derrick
    Signed-off-by: Revanth Rajashekar
    Signed-off-by: Jens Axboe

    Revanth Rajashekar
     

04 Nov, 2019

3 commits

  • This patch introduces Opal Datastore UID.
    The generic read/write table ioctl can use this UID
    to access the Opal Datastore.

    Reviewed-by: Scott Bauer
    Reviewed-by: Jon Derrick
    Signed-off-by: Revanth Rajashekar
    Signed-off-by: Jens Axboe

    Revanth Rajashekar
     
  • This feature gives the user RW access to any opal table with admin1
    authority. The flags described in the new structure determines if the user
    wants to read/write the data. Flags are checked for valid values in
    order to allow future features to be added to the ioctl.

    The user can provide the desired table's UID. Also, the ioctl provides a
    size and offset field and internally will loop data accesses to return
    the full data block. Read overrun is prevented by the initiator's
    sec_send_recv() backend. The ioctl provides a private field with the
    intention to accommodate any future expansions to the ioctl.

    Reviewed-by: Scott Bauer
    Reviewed-by: Jon Derrick
    Signed-off-by: Revanth Rajashekar
    Signed-off-by: Jens Axboe

    Revanth Rajashekar
     
  • This patch refactors the existing "write_shadowmbr" func and
    creates a new generalized function "generic_table_write_data",
    to write data to any opal table. Also, a few cleanups are included
    in this patch.

    Reviewed-by: Scott Bauer
    Reviewed-by: Jon Derrick
    Signed-off-by: Revanth Rajashekar
    Signed-off-by: Jens Axboe

    Revanth Rajashekar
     

04 Oct, 2019

2 commits

  • sparse warns about incorrect type when using __be64 data.
    It is not being converted to CPU-endian but it should be.

    Fixes these sparse warnings:

    ../block/sed-opal.c:375:20: warning: incorrect type in assignment (different base types)
    ../block/sed-opal.c:375:20: expected unsigned long long [usertype] align
    ../block/sed-opal.c:375:20: got restricted __be64 const [usertype] alignment_granularity
    ../block/sed-opal.c:376:25: warning: incorrect type in assignment (different base types)
    ../block/sed-opal.c:376:25: expected unsigned long long [usertype] lowest_lba
    ../block/sed-opal.c:376:25: got restricted __be64 const [usertype] lowest_aligned_lba

    Fixes: 455a7b238cd6 ("block: Add Sed-opal library")
    Cc: Scott Bauer
    Cc: Rafael Antognolli
    Cc: linux-block@vger.kernel.org
    Reviewed-by: Jon Derrick
    Signed-off-by: Randy Dunlap
    Signed-off-by: Jens Axboe

    Randy Dunlap
     
  • Fix sparse warning: (missing '=')
    ../block/sed-opal.c:133:17: warning: obsolete array initializer, use C99 syntax

    Fixes: ff91064ea37c ("block: sed-opal: check size of shadow mbr")
    Cc: linux-block@vger.kernel.org
    Cc: Jonas Rabenstein
    Cc: David Kozub
    Reviewed-by: Scott Bauer
    Reviewed-by: Revanth Rajashekar
    Signed-off-by: Randy Dunlap
    Signed-off-by: Jens Axboe

    Randy Dunlap
     

20 Aug, 2019

2 commits


30 Jun, 2019

3 commits

  • Check whether the shadow mbr does fit in the provided space on the
    target. Also a proper firmware should handle this case and return an
    error we may prevent problems or even damage with crappy firmwares.

    Signed-off-by: Jonas Rabenstein
    Signed-off-by: David Kozub
    Reviewed-by: Scott Bauer
    Reviewed-by: Jon Derrick
    Signed-off-by: Jens Axboe

    Jonas Rabenstein
     
  • Allow modification of the shadow mbr. If the shadow mbr is not marked as
    done, this data will be presented read only as the device content. Only
    after marking the shadow mbr as done and unlocking a locking range the
    actual content is accessible.

    Co-authored-by: David Kozub
    Signed-off-by: Jonas Rabenstein
    Signed-off-by: David Kozub
    Reviewed-by: Scott Bauer
    Reviewed-by: Jon Derrick
    Signed-off-by: Jens Axboe

    Jonas Rabenstein
     
  • Enable users to mark the shadow mbr as done without completely
    deactivating the shadow mbr feature. This may be useful on reboots,
    when the power to the disk is not disconnected in between and the shadow
    mbr stores the required boot files. Of course, this saves also the
    (few) commands required to enable the feature if it is already enabled
    and one only wants to mark the shadow mbr as done.

    Co-authored-by: David Kozub
    Signed-off-by: Jonas Rabenstein
    Signed-off-by: David Kozub
    Reviewed-by: Christoph Hellwig
    Reviewed by: Scott Bauer
    Reviewed-by: Jon Derrick
    Signed-off-by: Jens Axboe

    Jonas Rabenstein
     

29 Jun, 2019

2 commits

  • 'who' an unsigned variable in stucture opal_session_info
    can never be lesser than zero. Hence, the condition
    "who < OPAL_ADMIN1" can never be true.

    Signed-off-by: Revanth Rajashekar
    Signed-off-by: Jens Axboe

    Revanth Rajashekar
     
  • PSID is a 32 character password printed on the drive label,
    to prove its physical access. This PSID reverttper function
    is very useful to regain the control over the drive when it
    is locked and the user can no longer access it because of some
    failures. However, *all the data on the drive is completely
    erased*. This method is advisable only when the user is exhausted
    of all other recovery methods.

    PSID capabilities are described in:
    https://trustedcomputinggroup.org/wp-content/uploads/TCG_Storage-Opal_Feature_Set_PSID_v1.00_r1.00.pdf

    Signed-off-by: Revanth Rajashekar
    Signed-off-by: Jens Axboe

    Revanth Rajashekar
     

01 May, 2019

1 commit


07 Apr, 2019

16 commits

  • As the function is responsible for executing the individual steps supplied
    in the steps argument, execute_steps is a more descriptive name than the
    rather generic next.

    Signed-off-by: David Kozub
    Reviewed-by: Scott Bauer
    Reviewed-by: Christoph Hellwig
    Reviewed-by: Jon Derrick
    Signed-off-by: Jens Axboe

    David Kozub
     
  • Originally each of the opal functions that call next include
    opal_discovery0 in the array of steps. This is superfluous and
    can be done always inside next.

    Acked-by: Jon Derrick
    Reviewed-by: Christoph Hellwig
    Reviewed-by: Scott Bauer
    Signed-off-by: David Kozub
    Signed-off-by: Jens Axboe

    David Kozub
     
  • The steps argument is only read by the next function, so it can
    be passed directly as an argument rather than via opal_dev.

    Normally, the steps is an array on the stack, so the pointer stops
    being valid then the function that set opal_dev.steps returns.
    If opal_dev.steps was not set to NULL before return it would become
    a dangling pointer. When the steps are passed as argument this
    becomes easier to see and more difficult to misuse.

    Acked-by: Jon Derrick
    Reviewed-by: Christoph Hellwig
    Reviewed-by: Scott Bauer
    Signed-off-by: David Kozub
    Signed-off-by: Jens Axboe

    David Kozub
     
  • Replace integer literals by Opal tokens defined in opal_proto.h where
    possible.

    Reviewed-by: Christoph Hellwig
    Acked-by: Jon Derrick
    Reviewed-by: Scott Bauer
    Signed-off-by: David Kozub
    Signed-off-by: Jens Axboe

    David Kozub
     
  • Instead of having multiple places defining the same argument list to get
    a specific column of a sed-opal table, provide a generic version and
    call it from those functions.

    Co-authored-by: David Kozub
    Signed-off-by: Jonas Rabenstein
    Signed-off-by: David Kozub
    Reviewed-by: Scott Bauer
    Reviewed-by: Christoph Hellwig
    Reviewed-by: Jon Derrick
    Signed-off-by: Jens Axboe

    David Kozub
     
  • Define OPAL_LIFECYCLE token and use it instead of literals in
    get_lsp_lifecycle.

    Acked-by: Jon Derrick
    Reviewed-by: Christoph Hellwig
    Reviewed-by: Scott Bauer
    Signed-off-by: David Kozub
    Signed-off-by: Jens Axboe

    David Kozub
     
  • Split the header generation from the (normal) memcpy part if a
    bytestring is copied into the command buffer. This allows in-place
    generation of the bytestring content. For example, copy_from_user may be
    used without an intermediate buffer.

    Signed-off-by: Jonas Rabenstein
    Signed-off-by: David Kozub
    Reviewed-by: Scott Bauer
    Reviewed-by: Christoph Hellwig
    Reviewed-by: Jon Derrick
    Signed-off-by: Jens Axboe

    Jonas Rabenstein
     
  • Add function address (and if available its symbol) to the message if a
    step function fails.

    Signed-off-by: Jonas Rabenstein
    Signed-off-by: David Kozub
    Reviewed-by: Scott Bauer
    Reviewed-by: Christoph Hellwig
    Reviewed-by: Jon Derrick

    Jonas Rabenstein
     
  • response_get_token had already been in place, its functionality had
    been duplicated within response_get_{u64,bytestring} with the same error
    handling. Unify the handling by reusing response_get_token within the
    other functions.

    Co-authored-by: Jonas Rabenstein
    Signed-off-by: David Kozub
    Signed-off-by: Jonas Rabenstein
    Reviewed-by: Scott Bauer
    Reviewed-by: Christoph Hellwig
    Reviewed-by: Jon Derrick
    Signed-off-by: Jens Axboe

    David Kozub
     
  • response_get_{string,u64} include error handling for argument resp being
    NULL but response_get_token does not handle this.

    Make all three of response_get_{string,u64,token} handle NULL resp in
    the same way.

    Co-authored-by: Jonas Rabenstein
    Signed-off-by: David Kozub
    Signed-off-by: Jonas Rabenstein
    Reviewed-by: Scott Bauer
    Reviewed-by: Christoph Hellwig
    Reviewed-by: Jon Derrick
    Signed-off-by: Jens Axboe

    David Kozub
     
  • Every step starts with resetting the cmd buffer as well as the comid and
    constructs the appropriate OPAL_CALL command. Consequently, those
    actions may be combined into one generic function. On should take care
    that the opening and closing tokens for the argument list are already
    emitted by cmd_start and cmd_finalize respectively and thus must not be
    additionally added.

    Co-authored-by: Jonas Rabenstein
    Signed-off-by: David Kozub
    Signed-off-by: Jonas Rabenstein
    Reviewed-by: Scott Bauer
    Reviewed-by: Christoph Hellwig
    Acked-by: Jon Derrick
    Signed-off-by: Jens Axboe

    David Kozub
     
  • Every step ends by calling cmd_finalize (via finalize_and_send)
    yet every step adds the token OPAL_ENDLIST on its own. Moving
    this into cmd_finalize decreases code duplication.

    Co-authored-by: Jonas Rabenstein
    Signed-off-by: David Kozub
    Signed-off-by: Jonas Rabenstein
    Reviewed-by: Scott Bauer
    Reviewed-by: Christoph Hellwig
    Acked-by: Jon Derrick
    Signed-off-by: Jens Axboe

    David Kozub
     
  • All add_token_* functions have a common set of conditions that have to
    be checked. Use a common function for those checks in order to avoid
    different behaviour as well as code duplication.

    Acked-by: Jon Derrick
    Reviewed-by: Christoph Hellwig
    Reviewed-by: Scott Bauer
    Co-authored-by: David Kozub
    Signed-off-by: Jonas Rabenstein
    Signed-off-by: David Kozub
    Signed-off-by: Jens Axboe

    Jonas Rabenstein
     
  • Also the values of OPAL_UID_LENGTH and OPAL_METHOD_LENGTH are the same,
    it is weird to use OPAL_UID_LENGTH for the definition of the methods.

    Signed-off-by: Jonas Rabenstein
    Signed-off-by: David Kozub
    Reviewed-by: Scott Bauer
    Reviewed-by: Christoph Hellwig
    Reviewed-by: Jon Derrick
    Signed-off-by: Jens Axboe

    Jonas Rabenstein
     
  • This should make no change in functionality.
    The formatting changes were triggered by checkpatch.pl.

    Reviewed-by: Scott Bauer
    Reviewed-by: Jon Derrick
    Reviewed-by: Christoph Hellwig
    Signed-off-by: David Kozub
    Signed-off-by: Jens Axboe

    David Kozub
     
  • The implementation of IOC_OPAL_ENABLE_DISABLE_MBR handled the value
    opal_mbr_data.enable_disable incorrectly: enable_disable is expected
    to be one of OPAL_MBR_ENABLE(0) or OPAL_MBR_DISABLE(1). enable_disable
    was passed directly to set_mbr_done and set_mbr_enable_disable where
    is was interpreted as either OPAL_TRUE(1) or OPAL_FALSE(0). The end
    result was that calling IOC_OPAL_ENABLE_DISABLE_MBR with OPAL_MBR_ENABLE
    actually disabled the shadow MBR and vice versa.

    This patch adds correct conversion from OPAL_MBR_DISABLE/ENABLE to
    OPAL_FALSE/TRUE. The change affects existing programs using
    IOC_OPAL_ENABLE_DISABLE_MBR but this is typically used only once when
    setting up an Opal drive.

    Acked-by: Jon Derrick
    Reviewed-by: Christoph Hellwig
    Reviewed-by: Scott Bauer
    Signed-off-by: David Kozub
    Signed-off-by: Jens Axboe

    David Kozub
     

21 Jun, 2018

1 commit

  • resp->num is the number of tokens in resp->tok[]. It gets set in
    response_parse(). So if n == resp->num then we're reading beyond the
    end of the data.

    Fixes: 455a7b238cd6 ("block: Add Sed-opal library")
    Reviewed-by: Scott Bauer
    Tested-by: Scott Bauer
    Signed-off-by: Dan Carpenter
    Signed-off-by: Jens Axboe

    Dan Carpenter
     

06 Apr, 2018

1 commit

  • Pull block layer updates from Jens Axboe:
    "It's a pretty quiet round this time, which is nice. This contains:

    - series from Bart, cleaning up the way we set/test/clear atomic
    queue flags.

    - series from Bart, fixing races between gendisk and queue
    registration and removal.

    - set of bcache fixes and improvements from various folks, by way of
    Michael Lyle.

    - set of lightnvm updates from Matias, most of it being the 1.2 to
    2.0 transition.

    - removal of unused DIO flags from Nikolay.

    - blk-mq/sbitmap memory ordering fixes from Omar.

    - divide-by-zero fix for BFQ from Paolo.

    - minor documentation patches from Randy.

    - timeout fix from Tejun.

    - Alpha "can't write a char atomically" fix from Mikulas.

    - set of NVMe fixes by way of Keith.

    - bsg and bsg-lib improvements from Christoph.

    - a few sed-opal fixes from Jonas.

    - cdrom check-disk-change deadlock fix from Maurizio.

    - various little fixes, comment fixes, etc from various folks"

    * tag 'for-4.17/block-20180402' of git://git.kernel.dk/linux-block: (139 commits)
    blk-mq: Directly schedule q->timeout_work when aborting a request
    blktrace: fix comment in blktrace_api.h
    lightnvm: remove function name in strings
    lightnvm: pblk: remove some unnecessary NULL checks
    lightnvm: pblk: don't recover unwritten lines
    lightnvm: pblk: implement 2.0 support
    lightnvm: pblk: implement get log report chunk
    lightnvm: pblk: rename ppaf* to addrf*
    lightnvm: pblk: check for supported version
    lightnvm: implement get log report chunk helpers
    lightnvm: make address conversions depend on generic device
    lightnvm: add support for 2.0 address format
    lightnvm: normalize geometry nomenclature
    lightnvm: complete geo structure with maxoc*
    lightnvm: add shorten OCSSD version in geo
    lightnvm: add minor version to generic geometry
    lightnvm: simplify geometry structure
    lightnvm: pblk: refactor init/exit sequences
    lightnvm: Avoid validation of default op value
    lightnvm: centralize permission check for lightnvm ioctl
    ...

    Linus Torvalds
     

17 Mar, 2018

1 commit


07 Mar, 2018

1 commit

  • Tokens are prefixed by a variable length of bytes. If a bytestring is
    not stored in an tiny or short atom, we have to skip more than one byte
    in order to have the actual bytes not prefixed by the bytes describing
    the actual length of the string.

    Acked-by: Jonathan Derrick
    Signed-off-by: Jonas Rabenstein
    Signed-off-by: Jens Axboe

    Jonas Rabenstein
     

22 Feb, 2018

1 commit

  • On lkml suggestions were made to split up such trivial typo fixes into per subsystem
    patches:

    --- a/arch/x86/boot/compressed/eboot.c
    +++ b/arch/x86/boot/compressed/eboot.c
    @@ -439,7 +439,7 @@ setup_uga32(void **uga_handle, unsigned long size, u32 *width, u32 *height)
    struct efi_uga_draw_protocol *uga = NULL, *first_uga;
    efi_guid_t uga_proto = EFI_UGA_PROTOCOL_GUID;
    unsigned long nr_ugas;
    - u32 *handles = (u32 *)uga_handle;;
    + u32 *handles = (u32 *)uga_handle;
    efi_status_t status = EFI_INVALID_PARAMETER;
    int i;

    This patch is the result of the following script:

    $ sed -i 's/;;$/;/g' $(git grep -E ';;$' | grep "\.[ch]:" | grep -vwE 'for|ia64' | cut -d: -f1 | sort | uniq)

    ... followed by manual review to make sure it's all good.

    Splitting this up is just crazy talk, let's get over with this and just do it.

    Reported-by: Pavel Machek
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Ingo Molnar

    Ingo Molnar
     

11 Sep, 2017

1 commit

  • Users who are booting off their Opal enabled drives are having
    issues when they have a shadow MBR set up after s3/resume cycle.
    When the Drive has a shadow MBR setup the MBRDone flag is set to
    false upon power loss (S3/S4/S5). When the MBRDone flag is false
    I/O to LBA 0 -> LBA_END_MBR are remapped to the shadow mbr
    of the drive. If the drive contains useful data in the 0 -> end_mbr
    range upon s3 resume the user can never get to that data as the
    drive will keep remapping it to the MBR. To fix this when we unlock
    on S3 resume, we need to tell the drive that we're done with the
    shadow mbr (even though we didnt use it) by setting true to MBRDone.
    This way the drive will stop the remapping and the user can access
    their data.

    Acked-by Jon Derrick:
    Signed-off-by: Scott Bauer
    Signed-off-by: Jens Axboe

    Scott Bauer
     

08 Apr, 2017

1 commit


30 Mar, 2017

1 commit


09 Mar, 2017

1 commit