Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@alexandruradovici
Copy link
Contributor

@alexandruradovici alexandruradovici commented Jul 16, 2021

Pull Request Overview

This pull request adds a compatibility header to the TBF. This is the first version of such a header.

The idea is to add the ability to the kernel to ignore and not load the processes that do not meet the kernel compatibility constraints defined in this header.

This defines a fixed header that contains:

  • the exact kernel major version
  • the minimum kernel minor version

Processes that provide a KernelVersion header state that the exact required kernel version and the
minimum required kernel minor version. For instance, if a process specifies kernel version 2.12, this means it requires a kernel
version that is >= 2.12 and < 3.0.

Testing Strategy

This was tested using a Microbit v2 and libtock-c with the new elf2tab (tock/elf2tab#30).

EDIT: Tockloader seems to send over to the board unknown TLV headers as this works with the unmodified tockloader.

TODO or Help Wanted

  1. I'm not sure where to define the running kernel version. For now this is defined as two constants in kernel/src/lib.rs. Another idea was to define them within the Config structure. The printed kernel version is taken from the git release, which, at least for the development tree, is difficult to parse
  2. Improvement to the debug messages

Documentation Updated

  • Updated the relevant files in /docs, or no updates are required.

Formatting

  • Ran make prepush.

Comment on lines +93 to +94
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need some way to remember to update this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we auto generate/update this from git tags?

Copy link
Contributor

@bradjc bradjc Jul 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generate doesn't work if someone downloads the zip file and there is no git repo. But something that at least checked somehow would be nice.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wary of this kind of specification. For example, it means that we can't change a system call API for a particular device number without a major number increment. Defining "compatible" seems difficult.

Instead, I'd suggest that we add this to the end of the main header. It should either be present in every app, or not. It should include only a major version number, which relates to the ABI with the kernel. Anything further than that (compatibility) can be determined by the app itself, e.g., by probing if devices are installed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intent is for this (i.e. TLV id 7) to only specify kernel ABI. We wanted major and minor, because Tock 2.1 might include a new allow call that Tock 2.0 does not. We do need to make this clear in the docs.

We also thought that a TLV was an appropriate option for two reasons:

  1. We're not entirely sure this is the long term best way to handle this sort of compatibility checking. Using a TLV makes it easy to deprecate this in the future and possibly replace it with something else.
  2. Some boards/deployments might not want to include any compatibility information (and save the bytes in the header). They can easily omit the TLV.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I detailed this in the documentation.

@phil-levis phil-levis added the tock-2.0-include This PR will hopefully be included in the Tock 2.0 release. label Jul 24, 2021
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should error if enforce_kernel_version is true.

app_flash.as_ptr() as usize,
app_flash.as_ptr() as usize + app_flash.len() - 1,
process_name
process_name.unwrap_or("(no name)")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this change. Is this related?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its not related, but this would display the process name instead of Some(process_name). I suggest the same change at line 1452.

Co-authored-by: Brad Campbell <[email protected]>
Copy link
Contributor

@bradjc bradjc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to merge at least the elf2tab changes and release elf2tab before we merge this.

@bradjc
Copy link
Contributor

bradjc commented Jul 29, 2021

Or we could set required to false for now, and change it back closer to the actual 2.0 release.

@alexandruradovici
Copy link
Contributor Author

Or we could set required to false for now, and change it back closer to the actual 2.0 release.

As long is we change it back before we release 2.0 this should be fine.

@phil-levis
Copy link
Contributor

Let's do this right -- @alexandruradovici can you rebase tock/elf2tab#30 so we can review and merge? It seems like everyone is on-board and it all looks good, let's just do it.

@alexandruradovici
Copy link
Contributor Author

I rebased tock/elf2tab#30, I would be great if @alistair23 can take a look at it the merge was with the permissions header.

bors bot added a commit to tock/libtock-c that referenced this pull request Jul 30, 2021
221: Added kernel version and automatic update for elf2tab r=bradjc a=alexandruradovici

This PR adds 
- the command line for elf2tab to add the `KernelVersion` header
- the automatic updatce of elf2tab.

This is needed to add the `KernelVersion` header (tock/tock#2669)

Co-authored-by: Alexandru Radovici <[email protected]>
@bradjc
Copy link
Contributor

bradjc commented Jul 30, 2021

bors r+

@bors
Copy link
Contributor

bors bot commented Jul 30, 2021

@bors bors bot merged commit 102040d into tock:master Jul 30, 2021
tyler-potyondy pushed a commit to tyler-potyondy/libtock-c that referenced this pull request Mar 13, 2024
221: Added kernel version and automatic update for elf2tab r=bradjc a=alexandruradovici

This PR adds 
- the command line for elf2tab to add the `KernelVersion` header
- the automatic updatce of elf2tab.

This is needed to add the `KernelVersion` header (tock/tock#2669)

Co-authored-by: Alexandru Radovici <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kernel tock-2.0-include This PR will hopefully be included in the Tock 2.0 release. tock-libraries This affects libraries supported by the Tock project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants