Rework rustup/toolchain installation

Migrate "rust-toolchain", which sets a rustup toolchain override for the
directory, to the newer "rust-toolchain.toml" format[1] and rewrite the
toolchain-related logic in setup.sh. This has several benefits:

 - If the user already has rustup installed, we won't run the
   installation script again. That prevents us from messing with
   environments that set the rustup $PATH in a non-default way.
 - We no longer change rustup's system-wide default toolchain, which
   similarly prevents us from messing with the user's environment.
 - Thanks to the expanded capabilities of rust-toolchain.toml, users who
   build without first running "setup.sh" will get the components and
   targets they need in addition to the toolchain itself.
 - We now have a single source of truth for our preferred toolchain.
   setup.sh now just installs whatever's in rust-toolchain.toml instead
   of hardcoding a toolchain name.

[1] https://rust-lang.github.io/rustup/overrides.html#the-toolchain-file
diff --git a/.licenserc.yaml b/.licenserc.yaml
index ccce5cc..c65f735 100644
--- a/.licenserc.yaml
+++ b/.licenserc.yaml
@@ -26,7 +26,6 @@
     - '**/*.md'
     - 'LICENSE'
     - 'NOTICE'
-    - 'rust-toolchain'
     - '**/Cargo.lock'
     - '**/*.lds'
     - 'aarch64-unknown-optee-trustzone.json'
diff --git a/rust-toolchain b/rust-toolchain
deleted file mode 100644
index 513fbad..0000000
--- a/rust-toolchain
+++ /dev/null
@@ -1 +0,0 @@
-nightly-2021-09-20
diff --git a/rust-toolchain.toml b/rust-toolchain.toml
new file mode 100644
index 0000000..d482968
--- /dev/null
+++ b/rust-toolchain.toml
@@ -0,0 +1,23 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Toolchain override for rustup
+
+[toolchain]
+channel = "nightly-2021-09-20"
+components = ["rust-src"]
+targets = ["aarch64-unknown-linux-gnu", "arm-unknown-linux-gnueabihf"]
diff --git a/setup.sh b/setup.sh
index 4f8586a..50030b9 100755
--- a/setup.sh
+++ b/setup.sh
@@ -24,15 +24,23 @@
 cd "$(dirname "$0")"
 
 ##########################################
-# install Rust and select a proper version
-curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain nightly-2021-09-20
-source $HOME/.cargo/env
-rustup component add rust-src && rustup target install aarch64-unknown-linux-gnu arm-unknown-linux-gnueabihf
+# install rustup and stable Rust if needed
+if command -v rustup &>/dev/null ; then
+	rustup install stable
+else
+	curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
+	source "$HOME/.cargo/env"
+fi
+
+# Ensure the toolchain, components, and targets we've specified in
+# rust-toolchain.toml are ready to go. Since that file sets rustup's default
+# toolchain for the entire directory, all we need to do is run any
+# rustup-wrapped command to trigger installation. We've arbitrarily chosen
+# "cargo --version" since it has no other effect.
+cargo --version >/dev/null
 
 # install Xargo
-rustup default 1.56.0 && cargo +1.56.0 install xargo
-# switch to nightly
-rustup default nightly-2021-09-20
+cargo +stable install xargo
 
 ########################################################
 # initialize submodules: optee_os / optee_client / build